Fork me on GitHub

解决python3.5.2与virtualenv版本兼容问题

一、问题描述

在安装python3.5.2后以及安装virtualenv以后,通过virtualen创建虚拟环境出现如下问题:

[root@localhost virtualEnv]# virtualenv --python=python3 testEnv
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 7, in <module>
from virtualenv.__main__ import run_with_catch
File "/usr/local/python3.5.2/lib/python3.5/site-packages/virtualenv/__init__.py", line 3, in <module>
from .run import cli_run, session_via_cli
File "/usr/local/python3.5.2/lib/python3.5/site-packages/virtualenv/run/__init__.py", line 13, in <module>
from .plugin.activators import ActivationSelector
File "/usr/local/python3.5.2/lib/python3.5/site-packages/virtualenv/run/plugin/activators.py", line 6, in <module>
from .base import ComponentBuilder
File "/usr/local/python3.5.2/lib/python3.5/site-packages/virtualenv/run/plugin/base.py", line 9, in <module>
from importlib_metadata import entry_points
File "/usr/local/python3.5.2/lib/python3.5/site-packages/importlib_metadata/__init__.py", line 92
dist: Optional['Distribution'] = None
^
SyntaxError: invalid syntax

二、问题解决

这是因为python与virtualenv的版本不兼容造成,卸载并且重新安装16.6.0virtualenv的版本即可:

# 卸载之前的版本
[root@localhost virtualEnv]# pip3 uninstall virtualenv
Uninstalling virtualenv-20.4.2:
...

# 安装兼容版本
[root@localhost virtualEnv]# pip3 install virtualenv==16.6.0
Collecting virtualenv==16.6.0
...

 

posted @ 2021-03-06 11:05  iveBoy  阅读(1395)  评论(0编辑  收藏  举报
TOP