python-不能使用Homebrew安装的模块吗?

时间:2016-02-21 12:33:59

标签: python python-2.7 package virtualenv

我想在我的python virtualenv中使用essentia模块,而python的版本是2.7.6。 我执行后

 brew tap MTG/essentia

我无法在我的Pycharm中找到这个模块。

我还尝试使用

安装其他软件包,例如matplotlib
sudo pip install matplotlib

在我的virtualenv路径下。

The directory '/Users/username/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/username/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.
Requirement already satisfied (use --upgrade to upgrade): matplotlib in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.5 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): tornado in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pyparsing>=1.5.6 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib)
Collecting nose (from matplotlib)
/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/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 nose-1.3.7-py2-none-any.whl (154kB)
    100% |████████████████████████████████| 155kB 46kB/s
Requirement already satisfied (use --upgrade to upgrade): backports.ssl-match-hostname in /Library/Python/2.7/site-packages (from tornado->matplotlib)
Requirement already satisfied (use --upgrade to upgrade): singledispatch in /Library/Python/2.7/site-packages (from tornado->matplotlib)
Requirement already satisfied (use --upgrade to upgrade): certifi in /Library/Python/2.7/site-packages (from tornado->matplotlib)
Requirement already satisfied (use --upgrade to upgrade): backports-abc>=0.4 in /Library/Python/2.7/site-packages (from tornado->matplotlib)
Requirement already satisfied (use --upgrade to upgrade): six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from singledispatch->tornado->matplotlib)
Installing collected packages: nose
Successfully installed nose-1.3.7
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

我在Pycharm中检查过,但是在解释器中没有matplotlib模块。 如何在virtualenv中安装软件包?

2 个答案:

答案 0 :(得分:1)

您不应该使用brew安装python模块,而应使用pip。在OSX中,以下方法对我有用。

Desktop     $ virtualenv myproject # Create the virtual environment
Desktop     $ cd myproject # Change into that directory
Desktop     $ source bin/activate # Enter the virtual environment
(myproject) $ sudo pip install matplotlib # Install matplotlib
(myproject) $ deactivate # Exit from the virtual environment

here查看virtualenv的进一步说明。

答案 1 :(得分:1)

如果pip包不可用,您可以在本地python目录中找到brew安装。

快速修复:

  • 将essentia安装到您的本地环境。
  • 将本地essentia软件包附加到您的虚拟环境

<input type="text" placeholder="Username" class="label" id="username"><br> <input type="password" placeholder="Password" class="label" id="password"> $("#username").keypress(function() { if($(this).hasClass("label")) { $(this).removeClass("label"); $(this).val(""); } }); $("#password").keypress(function() { if($(this).hasClass("label")) { $(this).removeClass("label"); $(this).val(""); } });

长期修复:

  • 如果要在虚拟环境中完全包含软件包,请尝试将本地site-packages / essentia文件夹复制到虚拟环境中
  • 复制任何其他依赖项,例如site-packages / numpy。检查brew的Cellar(/ usr / local / Cellar)以获取其他依赖项