【问题标题】:Pyinstaller does not include geos_c.dll in venvPyinstaller 不在 venv 中包含 geos_c.dll
【发布时间】:2023-01-18 03:40:20
【问题描述】:

我有一个使用 Shapely 的项目,我想创建该项目的单个 exe 文件。 Pyinstaller 似乎没有将包含在 Shapely 中的 geos_c.dll 包含到 exe 中,但仅当我使用虚拟环境时才包含。我怎样才能使用 venv 包含它?

我可以用下面的简单代码重现这个问题。

from shapely.geometry import Point
print("ok")

在我的项目文件夹中,我使用命令设置了一个虚拟环境

python -m venv venv

然后我从 ./venv/Scripts/activate.bat 激活了 venv。激活后,我先用pip安装Shapely和Pyinstaller,使用Pyinstaller创建exe,代码如下

pyinstaller --onefile main.py

我可以看到有一个警告

WARNING: lib not found: geos_c.dll dependency of c:\.\venv\lib\site-packages\shapely\speedups\_speedups.cp37-win_amd64.pyd

geos_c.dll 在

C:\.\venv\Lib\site-packages\shapely\DLLs

当我通过命令提示符启动创建的 exe 时,出现以下错误:

OSError: Could not find geos_c.dll or load any of its variants

更新时间 2021-12-07

使用的 Python 版本是 3.7.9。

【问题讨论】:

  • 您使用的 Python 版本是多少?
  • 问题的 Python 版本更新。

标签: python pyinstaller shapely


【解决方案1】:

我有同样的问题,我的解决方案是将 .dll 文件添加到 .spec 文件

datas=[("yourpath\venv\lib\site-packages\shapely\DLLs\geos.dll", ".") ,("yourpath\venv\lib\site-packages\shapely\DLLs\geos_c.dll", ".")],

然后使用规范文件构建

pyinstaller demo.spec

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-02
    • 1970-01-01
    • 1970-01-01
    • 2020-11-08
    相关资源
    最近更新 更多