如何告诉Pyinstaller使用Python 3.5而不是2.7?

如何告诉Pyinstaller使用Python 3.5而不是2.7?,python,pyinstaller,Python,Pyinstaller,我正在尝试使用Pyinstaller从.py脚本构建一个可执行文件。问题是它使用Python2.7而不是Python3.5构建它,所以我的可执行文件甚至不会运行 cali@californiki-pc ~/Desktop $ pyinstaller --onefile Vocabulary.py 25 INFO: PyInstaller: 3.2.1 25 INFO: Python: 2.7.12 26 INFO: Platform: Linux-4.4.0-72-generic-x86_64

我正在尝试使用Pyinstaller从.py脚本构建一个可执行文件。问题是它使用Python2.7而不是Python3.5构建它,所以我的可执行文件甚至不会运行

cali@californiki-pc ~/Desktop $ pyinstaller --onefile Vocabulary.py 
25 INFO: PyInstaller: 3.2.1
25 INFO: Python: 2.7.12
26 INFO: Platform: Linux-4.4.0-72-generic-x86_64-with-LinuxMint-18.1-serena
26 INFO: wrote /home/cali/Desktop/Vocabulary.spec
31 INFO: UPX is not available.
32 INFO: Extending PYTHONPATH with paths
['/home/cali/Desktop', '/home/cali/Desktop']
32 INFO: checking Analysis
33 INFO: Building Analysis because out00-Analysis.toc is non existent
33 INFO: Initializing module dependency graph...
34 INFO: Initializing module graph hooks...
139 INFO: running Analysis out00-Analysis.toc
160 INFO: Caching module hooks...
164 INFO: Analyzing /home/cali/Desktop/Vocabulary.py
246 INFO: Processing pre-safe import module hook   _xmlplus
1991 INFO: Processing pre-find module path hook   distutils
2209 INFO: Loading module hooks...
2209 INFO: Loading module hook "hook-distutils.py"...
2210 INFO: Loading module hook "hook-xml.py"...
2959 INFO: Loading module hook "hook-httplib.py"...
2960 INFO: Loading module hook "hook-encodings.py"...
3427 INFO: Looking for ctypes DLLs
3428 INFO: Analyzing run-time hooks ...
3435 INFO: Looking for dynamic libraries
3663 INFO: Looking for eggs
3663 INFO: Python library not in binary depedencies. Doing additional searching...
3707 INFO: Using Python library /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
3710 INFO: Warnings written to /home/cali/Desktop/build/Vocabulary/warnVocabulary.txt
3768 INFO: checking PYZ
3768 INFO: Building PYZ because out00-PYZ.toc is non existent
3768 INFO: Building PYZ (ZlibArchive) /home/cali/Desktop/build/Vocabulary/out00-PYZ.pyz
4122 INFO: Building PYZ (ZlibArchive) /home/cali/Desktop/build/Vocabulary/out00-PYZ.pyz completed successfully.
4172 INFO: checking PKG
4172 INFO: Building PKG because out00-PKG.toc is non existent
4172 INFO: Building PKG (CArchive) out00-PKG.pkg
7322 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
7336 INFO: Bootloader /usr/local/lib/python2.7/dist-packages/PyInstaller/bootloader/Linux-64bit/run
7336 INFO: checking EXE
7336 INFO: Building EXE because out00-EXE.toc is non existent
7336 INFO: Building EXE from out00-EXE.toc
7337 INFO: Appending archive to ELF section in EXE /home/cali/Desktop/dist/Vocabulary
7352 INFO: Building EXE from out00-EXE.toc completed successfully.
我怎样才能克服这个问题

@编辑:

我试图按照Claudio的建议使用
pip3安装Pyinstaller
安装Pyinstaller,但我得到了:

cali@californiki-pc ~/Desktop $ pip3 install pyinstaller
Collecting pyinstaller
  Using cached PyInstaller-3.2.1.tar.bz2
Collecting setuptools (from pyinstaller)
  Using cached setuptools-35.0.1-py2.py3-none-any.whl
Collecting appdirs>=1.4.0 (from setuptools->pyinstaller)
  Using cached appdirs-1.4.3-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools->pyinstaller)
  Using cached packaging-16.8-py2.py3-none-any.whl
Collecting six>=1.6.0 (from setuptools->pyinstaller)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools->pyinstaller)
  Using cached pyparsing-2.2.0-py2.py3-none-any.whl
Building wheels for collected packages: pyinstaller
  Running setup.py bdist_wheel for pyinstaller ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-42qpk7iy/pyinstaller/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpmmn5007ppip-wheel- --python-tag cp35:
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for pyinstaller
  Running setup.py clean for pyinstaller
Failed to build pyinstaller
Installing collected packages: appdirs, six, pyparsing, packaging, setuptools, pyinstaller
  Running setup.py install for pyinstaller ... done
Successfully installed appdirs-1.4.3 packaging-16.8 pyinstaller-3.2.1 pyparsing-2.2.0 setuptools-35.0.1 six-1.10.0
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

要解决您面临的问题,请使用以下方法安装PyInstaller:

pip3安装程序

然后注意运行正确的一个(然后在不同的位置会有两个,一个在Python2.7模块的路径中,另一个在Python3.5模块的路径中)

刚刚在我的机器上安装了PyInstaller for Python 3.5:

$ pip3 install pyinstaller
Collecting pyinstaller
Collecting setuptools (from pyinstaller)
  Using cached setuptools-35.0.1-py2.py3-none-any.whl
Collecting six>=1.6.0 (from setuptools->pyinstaller)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting appdirs>=1.4.0 (from setuptools->pyinstaller)
  Using cached appdirs-1.4.3-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools->pyinstaller)
  Using cached packaging-16.8-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools->pyinstaller)
  Using cached pyparsing-2.2.0-py2.py3-none-any.whl
Installing collected packages: six, appdirs, pyparsing, packaging, setuptools, pyinstaller
Successfully installed appdirs-1.4.3 packaging-16.8 pyinstaller-3.2.1 pyparsing-2.0.3 setuptools-20.7.0 six-1.10.0
它安装没有问题。。。嗯

尝试:


(有关更多信息,请参阅-您并不是唯一遇到此问题的人)

只需在pyinstaller中设置一个选项-upx dir,指定python 3.5的路径即可。它也可以是虚拟环境。例如:

pyinstaller --upx-dir="$HOME/virtual-envs/<your-virtual-env>/lib/python3.5/site-packages/" <your-script>.py'
pyinstaller--upx dir=“$HOME/virtual envs//lib/python3.5/site packages/”.py'
试试:

py -3.5 -m PyInstaller Vocabulary.py --onefile

我认为它区分大小写

此命令的功能可能重复?为什么它有助于解决OP问题?OP询问如何使用python 3.5而不是2.7。py-3.5-m将强制Python3.5。
py -3.5 -m PyInstaller Vocabulary.py --onefile