pyinstaller 要求在 venv 和 -p 中确实提供的依赖项

问题描述

尝试使用 pyinstaller 将可执行的 python 模块转换为 .exe。所以我

  • 创建了一个环境:c:\python39\python.exe -m venv %DIR_BASE%,
  • 激活它:%DIR_BASE%\scripts\activate,最后
  • 写了一个包含 requirements.txt 行的 jsonschema,说
  • python -m pip install -r requirements.txt

现在是访问 pyinstaller.exe 的主命令。本身什么都不知道 我给它的 -p 参数之外的新环境,我希望它足够了:

C:\python39\scripts\pyinstaller
  -p "X:\paws\src\shared\python;X:\paws\PyEnv\Py39\Lib\site-packages;
    X:\paws\PyEnv\Py39\Lib\site-packages\jsonschema;
    X:\paws\PyEnv\Py39\Scripts"
  -n ptGui
  %DIR_BASE%\prototype_gui\__main__.py

唉,我得到了:

  File "c:\python39\lib\site-packages\pkg_resources\__init__.py",line 785,in resolve
    raise distributionNotFound(req,requirers)
pkg_resources.distributionNotFound: The 'jsonschema' distribution was not found
  and is required by the application

但是,我非常肯定它的环境(!)安装 打包成功:

(Py39) X:\paws\PyEnv\Py39\Lib\site-packages>ls -1 | grep jsonschema
jsonschema
jsonschema-3.2.0.dist-info

很确定这是一些初学者的误解。你们有没有人看到, 并且会告诉我怎么做才对?

解决方法

我可以回答我自己的问题。显然,在基础安装上安装 pyinstaller 是错误的,从那里使用它,并期望一切正常。

我现在用的不是 C:\python39\python -m pip install pyinstaller

X:\PyEnv\Py39\Scripts\activate
python -m pip install pyinstaller

产生特定于环境的 X:\PyEnv\Py39\Scripts\pyinstaller.exe。使用它一切都很好。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...