2017-03-01 346 views
1

我在我的系統上有Python 2.7 & 3.5。我使用OS X 10.12。 Python 2.7是系統上的默認設置。如何指定Python版本PyInstaller使用?

當使用樓宇PyInstaller ...

pyinstaller myscript.py 

... PyInstaller使用Python 2.7。

也許我錯過了它,但在PyInstaller文檔中找不到任何可以指定Python版本的文檔。

有誰知道如何限制PyInstaller使用非默認的Python版本3.5?

我試過建設使用Macports。

使用命令後....

sudo port select python python35 

我得到證實......

然後嘗試使用打造時...

pyinstaller main.py --onefile 

PyInstaller節目它的建設與2.7 ...

68 INFO: PyInstaller: 3.2.1 
68 INFO: Python: 2.7.13 

我哪裏錯了?

回答

2

當安裝pyinstaller使用pip3 install pyinstaller

0

我解決了在Windows類似的問題(10)使用VENV: 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 
相關問題