Can't load Python modules installed via pip from site-packages directory

后端 未结 5 556
遥遥无期
遥遥无期 2020-11-27 13:19

I am trying to install and use the Evernote module (https://github.com/evernote/evernote-sdk-python) . I ran pip install evernote and it says that the installat

相关标签:
5条回答
  • 2020-11-27 13:25

    I figured it out! I added this line:

    export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages

    to my .bash_profile and now I can import modules stored in that directory. Thanks for everyone who answered.

    0 讨论(0)
  • 2020-11-27 13:32

    /usr/bin/python is the executable for the python that comes with OS X. /usr/local/lib is a location for user-installed programs only, possibly from Python.org or Homebrew. So you're mixing different Python installs, and changing the python path is only a partial workaround for different packages being installed for different installations.

    In order to make sure you use the pip associated with a particular python, you can run python -m pip install <pkg>, or go look at what the pip on your path is, or is symlinked to.

    0 讨论(0)
  • 2020-11-27 13:32

    I faced similar problem,its related to /usr/local/lib/python2.7/site-packages had no read or write permission for group and other, and they were owned by root. This means that only the root user could access them.

    Try this:

    $ sudo chmod -R go+rX /usr/local/lib/python2.7/site-packages
    
    0 讨论(0)
  • 2020-11-27 13:49

    None of this helped me with my similar problem. Instead, I had to fix the newly installed files permissions to be able to import. This is usually an obvious thing, but not so much when you use sudo when installing module/packages.

    0 讨论(0)
  • 2020-11-27 13:51

    Simply just type in terminal:

    sudo pip install pillow
    

    and type import (whatever you like) or type from (whatever you like) import (whatever you like).

    0 讨论(0)
提交回复
热议问题