使用virtualenvwrapper创建python3 virtualenv的SyntaxError

时间:2016-08-12 15:17:18

标签: python-3.x virtualenv virtualenvwrapper

我刚尝试使用virtualenvwrapper创建一个python3 virtualenv,但它一直给我这个语法错误:

$ mkvirtualenv --python=/usr/local/bin/python3 virtualenv_name
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5'
New python executable in /path/to/virtualenvs/virtualenv_name/bin/python3.5
Also creating executable in /path/to/virtualenvs/virtualenv_name/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /path/to/virtualenvs/virtualenv_name/bin/predeactivate
virtualenvwrapper.user_scripts creating /path/to/virtualenvs/virtualenv_name/bin/postdeactivate
virtualenvwrapper.user_scripts creating /path/to/virtualenvs/virtualenv_name/bin/preactivate
virtualenvwrapper.user_scripts creating /path/to/virtualenvs/virtualenv_name/bin/postactivate
virtualenvwrapper.user_scripts creating /path/to/virtualenvs/virtualenv_name/bin/get_env_details
virtualenv virtualenv_name activated.

  File "<string>", line 1
    import distutils; print distutils.sysconfig.get_python_lib()
                                    ^
SyntaxError: invalid syntax

这是我的mkvirtualenv版本:

$ mkvirtualenv --version
15.0.3

1 个答案:

答案 0 :(得分:0)

当你为python升级pip时,可能会出现这种问题(Linux操作系统默认为python 2.7.x,如ubuntu / mint),忘记为python3升级pip