Installed virtualenv, but still getting "ModuleNotFoundError: No module named 'virtualenv'" error
Installed virtualenv, but still getting "ModuleNotFoundError: No module named 'virtualenv'" error
我正在使用 CentOS 7 并想要 运行 一个 "virtualenv" 命令。所以我尝试卸载并重新安装它...
[myuser@server ~]$ sudo pip uninstall virtualenv
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Cannot uninstall 'virtualenv'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
[myuser@server ~]$ sudo pip install virtualenv
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: virtualenv in /usr/lib/python2.7/site-packages (15.1.0)
但是当我真正去 运行 它时,我被告知它没有安装。
[myuser@server ~]$ virtualenv myenv
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 2, in <module>
import virtualenv
ModuleNotFoundError: No module named 'virtualenv'
WTF??
尝试python -m virtualenv myenv
。 -m
标志表示模块。使用此命令,您明确告诉 python 到 运行 模块 virtualenv
作为脚本。
您可以删除 virtualenv rm -r ./your_venv
,然后创建新的 python3 -m virtualenv your_venv
并激活此 source ./your_venv/bin/activate
。现在您处于分离的环境中。例如,在这种状态下,您可以安装您的库 pip install -r ./requirements.txt
。这些库将仅安装在您的环境中,而不是全局安装。
我正在使用 CentOS 7 并想要 运行 一个 "virtualenv" 命令。所以我尝试卸载并重新安装它...
[myuser@server ~]$ sudo pip uninstall virtualenv
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Cannot uninstall 'virtualenv'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
[myuser@server ~]$ sudo pip install virtualenv
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: virtualenv in /usr/lib/python2.7/site-packages (15.1.0)
但是当我真正去 运行 它时,我被告知它没有安装。
[myuser@server ~]$ virtualenv myenv
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 2, in <module>
import virtualenv
ModuleNotFoundError: No module named 'virtualenv'
WTF??
尝试python -m virtualenv myenv
。 -m
标志表示模块。使用此命令,您明确告诉 python 到 运行 模块 virtualenv
作为脚本。
您可以删除 virtualenv rm -r ./your_venv
,然后创建新的 python3 -m virtualenv your_venv
并激活此 source ./your_venv/bin/activate
。现在您处于分离的环境中。例如,在这种状态下,您可以安装您的库 pip install -r ./requirements.txt
。这些库将仅安装在您的环境中,而不是全局安装。