Virtualenv:未找到命令

2024-04-26 03:38:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我在尝试创建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信息响应:

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

Tags: installpipandthehttpsbuildsupportvirtualenv
1条回答
网友
1楼 · 发布于 2024-04-26 03:38:10

您已经根据brew info安装了Python2.7.10。python --version返回2.7.6,因此您可能正在使用与OS X捆绑的Python。若要解决此问题,请运行:brew link python,通过运行which python来确认它已正确链接。它应该返回/usr/local/bin/python(除非您在/usr/local之外的另一个目录中安装了自制程序)。

之后,您可能需要使用以前使用的命令重新安装virtualenv,因为brew link python还将更新pip(链接到/usr/local中的Python安装的pip版本)的路径。

相关问题 更多 >

    热门问题