成功安装包后找不到Python包

时间:2014-12-12 04:07:28

标签: python linkedin

我已经使用pip在我的python环境中安装了确实和linkedin软件包。

一切都显示为已成功安装,然后,当我通过终端启动我的python并进行导入时,它表示找不到模块。

我提到了thisthis论坛帖子。但是,他们的情况与我的情况略有不同。在我的情况下,包已经成功安装在正确的位置。但是,它似乎没有发现。

以下是一个例子:

安装linkedin包:

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$ 

通过新的终端窗口启动Python,以下是尝试导入linkedin包后的输出。

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']
>>> 

2 个答案:

答案 0 :(得分:3)

您需要将这些库文件夹(linkedin,httplib2,oauth2,simplejson)复制到:

&#39; /Library/Python/2.7/site-packages /&#39;

还有一件事,确保您的Eclipse Preference通过这种方式指向那里: 打开Eclipse - &gt;优先 - &gt; Pydev-&GT; Interpreters-&GT; Python解释器 - &gt;库选项卡。 确保&#39; /Library/Python/2.7/site-packages'已添加。

答案 1 :(得分:0)

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

from linkedin import linkedin