Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python-Can't use modules installed by Homebrew?

I want to use the essentia module in my python virtualenv and the version of python is 2.7.6. After I executed

 brew tap MTG/essentia

I can't find this module in my Pycharm.

I've also tried to install other package such as matplotlib using

sudo pip install matplotlib

under my virtualenv path.

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.

I checked in Pycharm, however, in the interpreter there was no matplotlib module. How can I install packages in my virtualenv?

like image 919
jinglei Avatar asked Oct 16 '25 04:10

jinglei


1 Answers

If the pip package is not available, you can find the brew installation in your local python directory.

Quick Fix:

  • Install essentia to your local environment.
  • Append the local essentia package to your virtual environment

sys.path.append('/usr/local/lib/python2.7/site-packages') import essentia

Long Fix:

  • If you want to fully contain the packages in your virtual environment, try copying the local site-packages/essentia folder to your virtual environment
  • Copy over any other dependencies such as site-packages/numpy. Check brew's Cellar (/usr/local/Cellar) for other dependencies
like image 95
Connor Avatar answered Oct 17 '25 19:10

Connor