简体   繁体   中英

Python package not found after installing package successfully

I have installed indeed and linkedin packages in my python environment using pip.

Everything shows up as successfully installed and then, when I start my python through the terminal, and do an import, it says module not found.

I referred to this and this forum post. However, their situation is slightly different than mine. In my case, the package is already installed successfully at the correct location. However, it does not seem to pick up.

Following is an example:

Installing linkedin package:

MacBook-Air:lib admin$ pip install linkedin
Downloading/unpacking linkedin
  Downloading linkedin-0.1.5.tar.gz
  Running setup.py (path:/private/var/folders/15/nylbk3955yz1y5_y17nysdfc0000gq/T/pip_build_admin/linkedin/setup.py) egg_info for package linkedin

Downloading/unpacking httplib2 (from linkedin)
  Downloading httplib2-0.9.tar.gz (204kB): 204kB downloaded
  Running setup.py (path:/private/var/folders/15/nylbk3955yz1y5_y17nysdfc0000gq/T/pip_build_admin/httplib2/setup.py) egg_info for package httplib2

Downloading/unpacking oauth2 (from linkedin)
  Downloading oauth2-1.5.211.tar.gz
  Running setup.py (path:/private/var/folders/15/nylbk3955yz1y5_y17nysdfc0000gq/T/pip_build_admin/oauth2/setup.py) egg_info for package oauth2

Downloading/unpacking simplejson (from linkedin)
  Downloading simplejson-3.6.5.tar.gz (73kB): 73kB downloaded
  Running setup.py (path:/private/var/folders/15/nylbk3955yz1y5_y17nysdfc0000gq/T/pip_build_admin/simplejson/setup.py) egg_info for package simplejson

Installing collected packages: linkedin, httplib2, oauth2, simplejson
  Running setup.py install for linkedin

  Running setup.py install for httplib2

  Running setup.py install for oauth2

  Running setup.py install for simplejson
    building 'simplejson._speedups' extension
    clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c simplejson/_speedups.c -o build/temp.macosx-10.9-x86_64-2.7/simplejson/_speedups.o
    clang -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.9-x86_64-2.7/simplejson/_speedups.o -o build/lib.macosx-10.9-x86_64-2.7/simplejson/_speedups.so

Successfully installed linkedin httplib2 oauth2 simplejson
Cleaning up...
MacBook-Air:lib admin$ 

Started Python through a new terminal window and following is the output after trying to import linkedin package.

MacBook-Air:lib admin$ python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import linkedin
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named linkedin
>>> import sys
>>> sys.path
['', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages']
>>> 

You need to copy these library folder (linkedin,httplib2, oauth2 ,simplejson) to:

'/Library/Python/2.7/site-packages/'.

One more thing, make sure your Eclipse Preference point to there by this way: open Eclipse -> Prefereces -> Pydev-> Interpreters-> Python Interpreter -> Libraries tab. make sure '/Library/Python/2.7/site-packages' is already added.

试试这个(来自一个例子):

from linkedin import linkedin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM