选择 pyinstaller 而非 py2exe 的原因可参考: 关于python打包成exe的一点经验之谈 .
For Windows, PyWin32 is a prerequisite. Follow that link and carefully read the instructions; there is a different version of PyWin32 for each version of Python. With this done you can continue to install pip using the MS-DOS command line. However it is particularly easy to use pip-Win, which sets up both pip and virtualenv and makes it simple to install packages and to switch between different Python interpreters. (For more on the uses of virtualenv, see Supporting Multiple Platforms below.) When pip-Win is working, enter this command in its Command field and click Run: venv -c -i pyi-env-name This creates a new virtual environment rooted at C:\Python\pyi-env-name and makes it the current environment. A new command shell window opens in which you can run commands within this environment. Enter the command pip install PyInstaller Whenever you want to use PyInstaller,
Then you have a command shell window in which commands execute in that environment. |
运行 pip-Win 会安装 pip 和 virtualenv, 在其中碰到两个问题.
> "C:\Python27\lib\mimetypes.py" 报 "UnicodeDecodeError"
这是一个 bug, 有个 patch 修复 http://bugs.python.org/file18143/9291.patch .
即将 mimetypes.py 中 "UnicodeEncodeError" 替换为 "UnicodeError" 即可.
> 下载 virtualenv 失败
手动在 https://pypi.python.org/pypi/virtualenv#downloads 下载 virtualenv-1.11.2-py2.py3-none-any.whl
执行 "C:\Python27\Scripts\pip.exe install virtualenv-1.11.2-py2.py3-none-any.whl" 即可.4. 在 pip-Win 的 "Command" 输入框中输入 "venv -c -i pyis", 并执行. 以后要进入创建的 pyis 只需执行 "venv pyis" .