对我来说很奇怪,因为每个教程都会讲述/usr/bin/python37,而对/library/frameworks/python.framework却一无所有 这还可以吗? 我做出了此答案后:
sudo pip3 install virtualenv
okay,我进行了卸载并使用-h sudo标志安装:
The directory '/Users/user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
但是当我尝试制作虚拟环境时,我得到了
Installing collected packages: virtualenv
Successfully installed virtualenv-16.4.3
检查Virtualenv位置:
$ virtualenv venv
-bash: /usr/local/bin/virtualenv: No such file or directory
为什么/library/frameworks/python.framework/? 为什么它在/usr/local/local/bin/virtualenv中搜索virtualenv? 在MacOS上编码总是如此痛苦吗?
使用酿造,您可以简单地使用“ VENV”。创建一个可以运行的虚拟环境 - >
$ which virtualenv
/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenv
示例:如果要为Django创建一个名称django_env
的虚拟环境
python3 -m venv environment_name
python3 -m venv django_env
deactivation:
source django_env/bin/activate
Python3Virtualenv设置 Quirtements:
python3Pip3
deactivate
PIP3与Python3一起安装 安装
$ brew install python3 #upgrade
$ pip3 install virtualenv
激活Virtualenv:
$ virtualenv -p python3 <desired-path>
deactivivever virtualenv:
$ source <desired-path>/bin/activate
您可以在fifficial页面上看到有关
$ deactivate
的更多信息。
用于Mac OS:
安装所需库:
运行以下命令
Homebrew
设置环境变量(如果需要):
brew install jpeg zlib libtiff libjpeg libpng freetype little-cms2 webp
export CFLAGS="-I$(brew --prefix)/include"
export LDFLAGS="-L$(brew --prefix)/lib"
仅如下:
$ source myvenv/bin/activate