尝试创建python 3虚拟环境时收到错误

时间:2015-04-12 14:31:23

标签: python python-3.x virtualenv

我默认使用python 2.7但是我也单独安装了python 3.5

 virtualenv -p /usr/local/bin/python3.5 kivyPy3.5

所以我正在尝试为kivy应用程序开发设置python 3.5虚拟环境,但是我收到以下错误:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/enum/__init__.py", line 371, in __getattr__
    return cls._member_map_[name]
KeyError: '_convert'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 23, in <module>
    import subprocess
  File "/usr/local/lib/python3.5/subprocess.py", line 364, in <module>
    import signal
  File "/usr/local/lib/python3.5/signal.py", line 8, in <module>
    _IntEnum._convert(
  File "/Library/Python/2.7/site-packages/enum/__init__.py", line 373, in __getattr__
    raise AttributeError(name)
AttributeError: _convert

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

Installation:
step 1:
>> sudo easy_install virtualenv

step 2:
Creating the First Virtual Environment

>> mkdir first_evn

>> virtualenv first_env/test_env
or
>> virtualenv first_env/test_env --no-site-packages

-no-site-packages:  If you don’t want to use any preinstalled packages from my operating system

step 3: activating environment

>> source /first_env/test_env/bin/activate

step 4: Deactivating Environment

>> deactivate

Important: if you  have more than one versions of Python on your server or local system and you want to create a viertualenv for a specific version of python then please replace the step 2 with following 

For Ubuntu
>>  virtualenv --python=/usr/bin/python3.3 first_env/test_env

For Window

>> virtualenv --python=c:\Python33\python.exe first_env/test_env

For mac
virtualenv --python=python3.4 test_env

Adding virtual env path in .base_profile file

>>> pico ~/.bash_profile

And add live alias ff='source ~/PATH_FROM_ROOT/VIRTUAL_ENV_NAME/bin/activate'

答案 1 :(得分:0)

此问题是由系统Python 2.7中安装的软件包enum34的版本引起的,该软件包与您尝试用于virtualenv的Python 3.5交互。

要解决此问题,请使用与您的系统Python 2.7 相关联的pip实例执行以下

pip install --upgrade enum34

这是关于它的Github问题对话。 https://github.com/pypa/virtualenv/issues/763