Ric*_*les 10 python virtualenv
我在尝试创建virtualenv文件夹时遇到问题,因为我的终端说virtualenv似乎没有安装.
我做了什么:
sudo pip install virtualenv
Run Code Online (Sandbox Code Playgroud)
有这个回应:
The directory '/Users/ricardogonzales/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/ricardogonzales/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.
Collecting virtualenv
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading virtualenv-13.1.0-py2.py3-none-any.whl (1.7MB)
100% |????????????????????????????????| 1.7MB 59kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-13.1.0
Run Code Online (Sandbox Code Playgroud)
之后我跑了virtualenv venv,我收到了这个回复:command not found
我brew info python像这里的其他人一样执行这个命令()同样的问题,但他们从终端的回复与我的不一样.
brew信息回复:
python: stable 2.7.10 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org
Not installed
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/python.rb
==> Dependencies
Build: pkg-config ?
Required: openssl ?
Recommended: readline ?, sqlite ?, gdbm ?
Optional: homebrew/dupes/tcl-tk ?, berkeley-db4 ?
==> Options
--universal
Build a universal binary
--with-berkeley-db4
Build with berkeley-db4 support
--with-poll
Enable select.poll, which is not fully implemented on OS X (https://bugs.python.org/issue5154)
--with-quicktest
Run `make quicktest` after the build (for devs; may fail)
--with-tcl-tk
Use Homebrew's Tk instead of OS X Tk (has optional Cocoa and threads support)
--without-gdbm
Build without gdbm support
--without-readline
Build without readline support
--without-sqlite
Build without sqlite support
--HEAD
Install HEAD version
==> Caveats
Pip and setuptools have been installed. To update them
pip install --upgrade pip setuptools
You can install Python packages with
pip install <package>
They will install into the site-package directory
/usr/local/lib/python2.7/site-packages
See: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md
Run Code Online (Sandbox Code Playgroud)
我不知道它是怎么说"没有安装"但是当我运行时python --version我得到Python 2.7.6但是如果我去usr/local/bin我看不到任何python 2.7或者我看到的东西是很多python3.
有帮助吗?或建议尝试解决这个问题将是非常好的.
回答:
我已经解决了这个问题卸载virtualenv并重新安装,没有任何额外的配置或东西.
sudo pip uninstall virtualenv
sudo pip install virtualenv
Run Code Online (Sandbox Code Playgroud)
您已根据 已安装 Python 2.7.10 brew info。python --version返回 2.7.6,因此您可能使用的是与 OS X 捆绑在一起的 Python。要修复该问题,请运行:brew link python,并通过运行 确认其链接正确which python。它应该返回/usr/local/bin/python(除非您已将 Homebrew 安装在除 之外的其他目录中/usr/local)。
之后,您可能需要使用之前使用过的命令重新安装 virtualenv,因为这brew link python也会更新路径pip(链接到您的 Python 安装的 pip 版本/usr/local)。