Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何指定PyInstaller使用的Python版本?_Python 3.x_Pyinstaller - Fatal编程技术网

Python 3.x 如何指定PyInstaller使用的Python版本?

Python 3.x 如何指定PyInstaller使用的Python版本?,python-3.x,pyinstaller,Python 3.x,Pyinstaller,我的系统上有Python 2.7和3.5。我正在使用OSX10.12。Python 2.7是系统上的默认版本 当使用 pyinstaller myscript.py …PyInstaller使用Python 2.7 也许我错过了它,但我在PyInstaller文档中找不到允许我指定Python版本的地方 有人知道如何约束PyInstaller使用非默认的Python版本3.5吗 我尝试过使用Macports构建 使用命令后 sudo port select python python35 我

我的系统上有Python 2.7和3.5。我正在使用OSX10.12。Python 2.7是系统上的默认版本

当使用

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

哪里出了问题?

安装pyinstaller时使用
pip3安装pyinstaller
我使用venv解决了Windows(10)上的类似问题:

我首先安装了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
Python35-32\python-m venv
光盘
.\Scripts\activate
pip安装程序
pyinstaller-F-c buildtest.py