编程语言
首页 > 编程语言> > python – cxfreeze在virtualenv中缺少distutils模块

python – cxfreeze在virtualenv中缺少distutils模块

作者:互联网

python3.2项目运行cxfreeze二进制文件时,我收到以下运行时错误:

/project/dist/project/distutils/__init__.py:13: UserWarning: The virtualenv distutils package at %s appears to be in the same location as the system distutils?
Traceback (most recent call last):
  File "/home/chrish/.virtualenvs/project/lib/python3.2/distutils/__init__.py", line 19, in <module>
    import dist
ImportError: No module named dist

相应地,cxfreeze输出的缺失模块部分中有几个distutils条目:

? dist imported from distutils
? distutils.ccompiler imported from numpy.distutils.ccompiler
? distutils.cmd imported from setuptools.dist
? distutils.command.build_ext imported from distutils
? distutils.core imported from numpy.distutils.core
...

我已经尝试强制distutils作为模块包含在内,通过在我的主python文件中导入它并将其添加到cxfreeze setup.py中:

options = {"build_exe": {"packages" : ["distutils"]} },

两种方法都不奏效.似乎我已经以某种方式破坏了virtualenv [因为distutils似乎是基本的并且关于distutils的位置的警告],重复一个干净的virtualenv复制了这个问题.

值得注意的是,我通过运行$VIRTUAL_ENV / build / cx-freeze / setup.py install来安装cx-freeze,因为它没有在pip中干净地安装.

解决方法:

总结我的意见:

virtualenv中的distutils副本正在做一些让cx_Freeze混淆的奇怪事情.简单的解决方法是在virtualenv之外冻结,以便它使用distutils的系统副本.

在Ubuntu上,Python 2和3很高兴共存:只需使用python3对Python 3做任何事情.在Python 3下安装cx_Freeze:python3 setup.py install.

标签:python,virtualenv,cx-freeze,distutils
来源: https://codeday.me/bug/20191008/1871894.html