我在Windows服务器2012R2上,试图在virtualenv中用py2exe编译一个脚本,每当应用程序脚本试图“导入distutils”时,我都会遇到问题(在我的例子中,它在第三方库中的某个地方,但我在这里减少了问题)。在
复制步骤:
创建虚拟环境
virtualenv venv
call venv\Scripts\activate
在virtualenv中安装py2exe
easy_install --always-unzip py2exe-0.6.9.win64-py2.7.amd64.exe
创建设置.py在
from distutils.core import setup
try:
import py2exe
except:
pass
setup(
console=[
'py2exe_distutils.py'
]
)
创建py2exe_distutils.py在
import distutils
运行py2exe
python setup.py py2exe
尝试运行生成的可执行文件
dist\py2exe_distutils.exe
它返回:
C:\Users\root\p\dist\library.zip\distutils\__init__.py:14: UserWarning: The virtualenv distutils package at %s appears to be in the same location as the system distutils?
Traceback (most recent call last):
File "py2exe_distutils.py", line 6, in <module>
import distutils
File "distutils\__init__.pyc", line 25, in <module>
ImportError: cannot import name dist
当我直接运行脚本(pythonpy2exe)时,它运行得很好_distutils.py)即使是在虚拟世界里。在
我是在尝试做一些py2exe不支持的操作,还是我的设置有问题?在
我在创建一个使用pandas0.12.0的可执行文件时遇到了同样的问题。这对我很有效:在创建可执行文件之前,从基本python安装中复制
distutils
文件夹我在Windows7Professional上使用VirtualEnv12.0.4和py2exe 0.6.6。可以找到一些额外的见解here。This answer向我指出了复制文件的方向。在
相关问题 更多 >
编程相关推荐