【问题标题】:Virtualenv: Command not foundVirtualenv:找不到命令
【发布时间】:2017-05-03 00:56:13
【问题描述】:

我在尝试创建我的 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),但他们的终端响应与我的不同。

酿造信息响应:

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

【问题讨论】:

  • sudo apt-get install virtualenv
  • @IanAuld 我忘了告诉我我使用的是 Mac OS X
  • 您可能需要注销/登录才能使用它,并使用mkvirtualenv 而不是virtualenv
  • 我不知道有什么不同的东西叫virtualvenv?它是virtualenv,就像virtual environment。您在整个问题中始终使用额外的“v”来拼写。
  • 你能在链接 Python 后发布which virtualenvwhich pip 的输出吗(见我的回答)?

标签: python virtualenv


【解决方案1】:

您已根据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 的路径(与/usr/local 中的 Python 安装链接的 pip 版本) )。

【讨论】:

  • 到达这里是因为在通过pip 安装后几个小时我无法让autopep8 正常工作(在过去的 24 小时内我一​​定是在尝试为 AWS 设置东西时严重搞砸了一些事情EC2 命令行工具包)。尝试在文件上运行 autopep8 时,我不断收到 -bash: command: not found 错误。无论如何,现在一切都很顺利,谢谢!
猜你喜欢
  • 2017-05-03
  • 1970-01-01
  • 2020-08-13
  • 2016-04-09
  • 2015-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多