WORKON_HOME由于错误,我忘记在创建虚拟环境之前指定变量,并且它们是在/root/.virtualenvs目录中创建的。它们工作得很好,我通过激活某些环境进行了一些测试,然后查看(env)$ pip freeze那里安装了哪些特定模块。
因此,当我发现工作主路径错误时,我需要将主机目录更改为/usr/local/pythonenv. /root/.virtualenvs我创建了它并将目录的所有内容移动到/usr/local/pythonenv,并更改了变量的值WORKON_HOME。现在,使用 workon 命令激活环境似乎工作正常(即,promt 更改为(env)$),但是如果我这样做(env)$ pip freeze,我会得到比以前更长的模块列表,并且这些模块不包括移动之前安装在该特定环境中的模块。
我想仅仅移动文件并为WORKON_HOME变量指定另一个目录是不够的。是否有一些配置可以在其中指定主机目录的新位置,或者特定环境的一些配置文件?
我正在尝试让 virtualenvwrapper 运行。我安装它:
sudo pip install virtualenvwrapper
Run Code Online (Sandbox Code Playgroud)
我像这样编辑了 .bashrc:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
Run Code Online (Sandbox Code Playgroud)
当我尝试运行“source ~/.bashrc”时,出现此错误:
/usr/bin/python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
Run Code Online (Sandbox Code Playgroud)
我在以下目录中安装了 pip、python 和 virtualenv:
which python
/usr/bin/python
which pip
/usr/bin/pip
which virtualenv
/usr/local/bin/virtualenv
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我正在尝试按照本指南使用 virtualenvwrapper 为我的 Django 项目设置 virtualenv:Django 教程。但是,在安装和写入后,
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
Run Code Online (Sandbox Code Playgroud)
并尝试运行 source ~/.bash_profile,我一直没有收到目录错误。我研究了这个错误,并认为错误不断出现是因为我用自制软件安装了 python3。
因此,我将 VIRTUALENVWRAPPER_PYTHON 目录更改为 /usr/local/Cellar/python/3.6.4_4 virtualenvwrapper.sh。
但现在我收到此错误:
virtualenvwrapper_run_hook:12: permission denied: /usr/local/Cellar/python/3.6.4_4
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/Cellar/python/3.6.4_4 and that PATH is
set properly.
Run Code Online (Sandbox Code Playgroud)
如何重置 PATH 以便我可以使用 virtualenvwrapper?
我在 Ubuntu WSL 上并virtualenvwrapper使用sudo apt install.
根据需要,变量WORKON_HOME已正确设置为我的虚拟 envs 目录。
当我运行时mkvirtualenv myawesomeproject,出现以下错误:
created virtual environment CPython3.8.2.final.0-64 in 760ms
creator CPython3Posix(dest=/home/fred/venvs/myawesomeproject, clear=False, global=False)
seeder FromAppData(download=False, CacheControl=latest, appdirs=latest, certifi=latest, chardet=latest, colorama=latest, contextlib2=latest, distlib=latest, distro=latest, html5lib=latest, idna=latest, ipaddr=latest, lockfile=latest, msgpack=latest, packaging=latest, pep517=latest, pip=latest, pkg_resources=latest, progress=latest, pyparsing=latest, pytoml=latest, requests=latest, retrying=latest, setuptools=latest, six=latest, urllib3=latest, webencodings=latest, wheel=latest, via=copy, app_data_dir=/home/fred/.local/share/virtualenv/seed-app-data/v1.0.1.debian)
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Command '' not found, but can be installed with:
sudo apt install mailutils-mh # version 1:3.7-2.1, or
sudo …Run Code Online (Sandbox Code Playgroud) 让virtualenv工作我遇到了很多麻烦.
首先我通过pip安装它,然后尝试设置virtualenv.这不起作用,我收到此错误消息:
ResNets-iMac:desktop zachary$ virtualenv anothertest
Using base prefix '/Applications/Canopy.app/appdata/canopy-1.5.1.2730.macosx-x86_64/Canopy.app/Contents'
New python executable in anothertest/bin/python
dyld: Library not loaded: @rpath/Python
Referenced from: /Users/zachary/Desktop/anothertest/bin/python
Reason: image not found
ERROR: The executable anothertest/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/Users/zachary/Desktop' (should be u'/Users/zachary/Desktop/anothertest')
ERROR: virtualenv is not compatible with this system or executable
Run Code Online (Sandbox Code Playgroud)
然后,我完成了所有可能的故障排除,并决定Canopy是问题所在.所以我删除了,重新安装了virualenv(通过'pip uninstall virtualenv'然后'pip install virtualenv'),现在每当我尝试做任何涉及virtualenv的事情时我都会收到此错误:
dyld: Library not loaded: @rpath/Python
Referenced from: /Users/zachary/Library/Enthought/Canopy_64bit/User/bin/python
Reason: image not found
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么做,当我检查我的默认版本的python是什么时,我得到:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Run Code Online (Sandbox Code Playgroud)
我对这一切都很新,我真的不知道我一直在做什么,或者如何解决这个问题,所以任何帮助都会非常感激.
谢谢!
我为一个项目创造了一个virtualenv环境."workon projectname"工作并激活了环境,但在关闭笔记本电脑后,它开始无法正常工作.有人能告诉我如何解决这个问题吗?
我尝试在Mac上安装virtualenvwrapper并获得经典的python catch 22:
C02QPBHWFVH3MBP:~ ckc3153$ pip install virtualenvwrapper
Collecting virtualenvwrapper
Using cached virtualenvwrapper-4.7.2.tar.gz
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Python/2.7/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in /Library/Python/2.7/site-packages (from virtualenvwrapper)
Collecting stevedore (from virtualenvwrapper)
Using cached stevedore-1.17.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): pbr>=1.6 in /Library/Python/2.7/site-packages (from stevedore->virtualenvwrapper)
Collecting six>=1.9.0 (from stevedore->virtualenvwrapper)
Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six, stevedore, virtualenvwrapper
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project …Run Code Online (Sandbox Code Playgroud) 我的操作系统 (Arch Linux) 最近将 Python 从 3.5.2 更新到 3.6.0,现在运行任何终端时我都会收到以下消息:
/usr/bin/python: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
Run Code Online (Sandbox Code Playgroud)
此外我得到这些输出
$ whereis python
python: /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python3.6-config /usr/bin/python3.6m-config /usr/bin/python2.7-config /usr/bin/python /usr/bin/python2.7 /usr/lib/python3.6 /usr/lib/python3.5 /usr/lib/python2.7 /usr/include/python3.6m /usr/include/python2.7 /usr/share/man/man1/python.1.gz
$ which python
/usr/bin/python
$ python --version
Python 3.6.0 …Run Code Online (Sandbox Code Playgroud) 使用 virtualenv 我可以通过 th 选项将 python 版本设置为特定的虚拟环境-p。这意味着对于不同的环境我可以设置不同的 python 版本。virtualenvwrapper 是否有类似的可能性?请注意,我不想设置在所有虚拟环境中使用的系统范围版本。我希望能够灵活地在虚拟环境级别设置 python 版本。
我正在尝试使用Windows 10命令提示符创建和激活虚拟环境。我知道virtualenv作为命令正确安装
virtualenv venv
Run Code Online (Sandbox Code Playgroud)
作品。我已经导航到我的virtualenv下载文件,Downloads \ venv \ Scripts,并且正在尝试激活我的虚拟环境venv。我试过了
venv activate
Run Code Online (Sandbox Code Playgroud)
由于Windows无法将venv识别为命令,因此无法使用。我也尝试过
virtualenv venv activate
Run Code Online (Sandbox Code Playgroud)
这也行不通,因为virtualenv表示“ venv activate”不是有效的参数。
如何在virtualenv包装器中为某个虚拟环境设置位置?
我为我现有的以及将来的大多数项目仍能参与其中而感到高兴
~/.virtualenv
Run Code Online (Sandbox Code Playgroud)
但是我希望我的Web项目虚拟环境位于我的Web项目文件夹中。
谢谢
我使用 RPI3B 并尝试安装 Virtualenvwrapper 和 Virtualenvs。在我添加之后
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
Run Code Online (Sandbox Code Playgroud)
在 ~/.profile 中。然后source ~ ~/.profile
我使用mkvirtualenv cv -p python2. 之后我收到这些消息:
created virtual environment CPython2.7.16.final.0-32 in 672ms
creator CPython2Posix(dest=/home/pi/.virtualenvs/cv, clear=False, global=False)
seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy,
app_data_dir=/home/pi/.local/share/virtualenv/seed-v1)
activators PythonActivator,CShellActivator,FishActivator,PowerShellActivator,BashActivator
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/cv/usr/local/bin/predeactivate
ERROR: Environment '/home/pi/.virtualenvs/cv' does not contain an activate script.
Run Code Online (Sandbox Code Playgroud)
但我不能使用 workon cv。最后的消息一次又一次地出现。我该如何解决?我也尝试重新安装,但没有帮助。
python virtualenv virtualenvwrapper raspberry-pi raspberry-pi3
我使用以下方法创建了一个虚拟环境:
mkvirtualenv env_name --python=python3.9
Run Code Online (Sandbox Code Playgroud)
然后我尝试从 Pipfile 安装:
pipenv install --dev
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
pipenv.patched.notpip._internal.exceptions.UnsupportedPythonVersion: pylint requires Python '~=3.6' but the running Python is 2.7.17
Run Code Online (Sandbox Code Playgroud)
我检查了我的Python版本,它是正确的:
$ python --version
Python 3.9.1
Run Code Online (Sandbox Code Playgroud)
为什么它告诉我我的 python 版本是 2.7.17?当我使用以下命令安装时,不会发生这种情况:
pip install pylint==2.7.2
Run Code Online (Sandbox Code Playgroud) virtualenv ×11
python ×9
macos ×2
pip ×2
python-2.7 ×2
python-3.x ×2
archlinux ×1
django ×1
homebrew ×1
pipenv ×1
raspberry-pi ×1
ubuntu-20.04 ×1