我有Python 2.7& 3.5在我的系统上。我正在使用OS X 10.12。 Python 2.7是系统的默认设置。
使用...构建PyInstaller时
pyinstaller myscript.py
... PyInstaller使用Python 2.7。
也许我错过了,但我在PyInstaller文档中找不到允许我指定Python版本的任何地方。
有谁知道如何限制PyInstaller使用非默认的Python版本3.5?
我尝试使用Macports构建。
使用命令....
sudo port select python python35
我得到了确认......
Selecting 'python35' for 'python' succeeded. 'python35' is now active.
然后在尝试构建时使用...
pyinstaller main.py --onefile
PyInstaller用2.7 ......
显示它的构建68 INFO: PyInstaller: 3.2.1
68 INFO: Python: 2.7.13
我哪里错了?
答案 0 :(得分:2)
安装pyinstaller时使用pip3 install pyinstaller
答案 1 :(得分:0)
我使用venv在Windows(10)上解决了类似的问题: https://docs.python.org/3/library/venv.html
我首先安装了python(3.5.2)的版本,我认为它可以与PyInstaller(3.2.1)一起使用。然后我创建了一个虚拟环境。接下来我激活了那个venv。安装了pyinstaller并运行了pyinstaller。
它使我的可执行文件正常,而PyInstaller:3.2.1在Python中失败:3.6.1。
这是一些伪cmd行命令,但您可以通过阅读上面的URL获得想法。
Python35-32\python -m venv <venvpath>
cd <venvpath>
.\Scripts\activate
pip install PyInstaller
pyinstaller -F -c buildtest.py