找不到 Pyinstaller 命令(MacOS)

问题描述 投票:0回答:5

我一直在尝试在我的程序 scrap_1.py 上使用 PyInstaller。 PyCharm项目文件夹名为“idigen”,保存在我的桌面上。所以,我就这样换了导演:

cd /Users/joelsaarinen/Desktop/idigen

然后,继续使用 pyinstaller,我收到此错误:

pyinstaller scratch_1.py
-bash: pyinstaller: command not found

我很困惑,因为当我使用时:

pip show pyinstaller

为了验证我是否安装了 pyinstaller,它返回了一个积极的结果。

在我的一个文件上使用 Pyinstaller 时是否应该输入额外的命令?这可能是这个特定程序或整个操作系统的问题吗?提前致谢。

python macos pip pyinstaller
5个回答
2
投票

这是一个常见问题,因为您可能安装了不同版本的 python 并继续使用机器中预安装的旧版本。这是最好的解决方案。

首先,检查您安装的Python版本。就我而言,我安装了 python 3.5,机器安装了 python2.7。如果您在终端上运行

python
,很可能会运行预安装的那个。

其次,检查你想要的Python版本的目录

watch -a python3
是运行以查看您的目录的命令。

第三,将目录设置为运行 python 命令的主要目录

alias python=/usr/local/bin/python3
完成全部技巧

最后,重新安装pip。下载 get-pip.py 文件并运行

sudo /usr/local/bin/python3 get-pip.py
* 我使用路径来显示我们更新别名的原因*

现在您可以毫无问题地运行

pyinstaller


1
投票

pyinstaller 似乎已正确安装,但该命令在 PATH 上不可用。您需要找到可执行文件的放置位置。`如下查找可执行文件

设置| grep pyinstaller

现在通过这个修改路径

 export PATH=some_path:another_path
launchctl setenv PATH $PATH

0
投票

我刚刚从官方网站下载了 pyInstaller 的源代码,将其放在我能找到的地方,并编写了一个从该文件夹启动

pyinstaller.py
的脚本。 由于某种原因,通过
pyinstaller.py
下载的 pyInstaller 安装中缺少
pip


0
投票

我在使用 Developer Tools 11.4 的 MacOS 上遇到了同样的问题,并找到了两种启动 pyinstaller 的方法:

替代方案 1:基于路径的解决方案

$ pip3 show -f pyinstaller|grep pyinstaller

将在

bin
路径中找到pyinstaller:

../../../../usr/local/bin/pyinstaller
...

因此,您可以使用设置路径或别名方法之一或通过完全限定路径进行调用。

替代2:通过python模块调用

$ pip3 show -f pyinstaller|grep __init__

将提示您如何将 pyinstaller 定义为模块:

PyInstaller/__init__.py
...

使用该大写字母,可以使用以下命令将 pyinstaller 作为模块调用:

$ python3 -m PyInstaller --version      
4.2

我现在用的是后者。


0
投票

使用root帐户“sudo su”安装可以找到pyinstaller命令

© www.soinside.com 2019 - 2024. All rights reserved.