我在尝试创建virtualenv文件夹时遇到问题,因为我的终端说virtualenv似乎没有安装。
我做了什么:
sudo pip install virtualenv
有了这个回复:
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
之后我运行了virtualenv venv
并得到了回复:command not found
我和其他人一样执行此命令(brew info python
)并遇到同样的问题,但他们对终端的回复与我的回答不一样。
brew info response:
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
我不知道它是怎么说“未安装”但是当我运行python --version
时我得到Python 2.7.6
但是如果我去usr / local / bin我看不到任何python 2.7或者我看到的东西是很多python3。
有任何帮助吗?或试图解决这个问题的建议将非常明确。
解答:
我已经解决了这个问题,卸载virtualenv并在没有任何额外配置的情况下重新安装。
sudo pip uninstall virtualenv
sudo pip install virtualenv
答案 0 :(得分:3)
您已根据brew info
安装了Python 2.7.10。 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安装在/usr/local
)。