简体   繁体   English

Python 找不到已安装的 pyinstaller 模块

[英]Python could not find installed pyinstaller module

I am using Mac OS Big Sur and Python 3.7.我正在使用 Mac OS Big Sur 和 Python 3.7。 I am trying to create an executable file from my python script with pyinstaller, but my python interpreter could not find pyinstaller even though it seems to be installed.我正在尝试使用 pyinstaller 从我的 python 脚本创建一个可执行文件,但我的 python 解释器无法找到 pyinstaller,即使它似乎已安装。

$ /usr/local/bin/python3.7 -m pyinstaller
/usr/local/opt/python/bin/python3.7: No module named pyinstaller

Here you can see pyinstaller is installed.在这里您可以看到 pyinstaller 已安装。

$ /usr/local/bin/python3.7 -m pip list
Package                   Version
------------------------- -------
altgraph                  0.17.2 
appdirs                   1.4.4  
colour                    0.1.5  
distlib                   0.3.1  
filelock                  3.0.12 
importlib-metadata        3.7.0  
macholib                  1.16   
pip                       19.1.1 
pyinstaller               5.2    
pyinstaller-hooks-contrib 2022.8 
setuptools                41.0.1 
six                       1.15.0 
tkmacosx                  1.0.5  
typing-extensions         3.7.4.3
virtualenv                20.4.2 
wheel                     0.33.4 
zipp                      3.4.0  
$ /usr/local/bin/python3.7 -m pip install pyinstaller
Requirement already satisfied: pyinstaller in /usr/local/lib/python3.7/site-packages (5.2)
Requirement already satisfied: altgraph in /usr/local/lib/python3.7/site-packages (from pyinstaller) (0.17.2)
Requirement already satisfied: pyinstaller-hooks-contrib>=2021.4 in /usr/local/lib/python3.7/site-packages (from pyinstaller) (2022.8)
Requirement already satisfied: importlib-metadata; python_version < "3.8" in /usr/local/lib/python3.7/site-packages (from pyinstaller) (3.7.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (from pyinstaller) (41.0.1)
Requirement already satisfied: macholib>=1.8; sys_platform == "darwin" in /usr/local/lib/python3.7/site-packages (from pyinstaller) (1.16)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/site-packages (from importlib-metadata; python_version < "3.8"->pyinstaller) (3.4.0)
Requirement already satisfied: typing-extensions>=3.6.4; python_version < "3.8" in /usr/local/lib/python3.7/site-packages (from importlib-metadata; python_version < "3.8"->pyinstaller) (3.7.4.3)

Any help is greatly appreciated!任何帮助是极大的赞赏!

Pyinstaller has a console_scripts entry point. Pyinstaller 有一个 console_scripts 入口点。 So you can directly run from the console.所以你可以直接从控制台运行。

Instead of /usr/local/bin/python3.7 -m pyinstaller , just run pyinstaller command directly, eg: pyinstaller --version而不是/usr/local/bin/python3.7 -m pyinstaller ,只需直接运行pyinstaller命令,例如: pyinstaller --version

If you are using virtual environment, activate that first before running pyinstaller commands.如果您使用的是虚拟环境,请在运行 pyinstaller 命令之前先激活它。

You can also run it by using PyInstaller instead of using pyinstaller .您也可以使用PyInstaller而不是pyinstaller来运行它。

Eg: /usr/local/bin/python3.7 -m PyInstaller --version例如: /usr/local/bin/python3.7 -m PyInstaller --version

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM