Python无法看到已安装的模块`news`

时间:2017-04-08 18:52:38

标签: python python-module

Python声明未安装news模块:

$ python -c "import news"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named news

即使:

$ pip show news
Name: news
Version: 1.0
Summary: my first python module
Home-page: UNKNOWN
Author: sang
Author-email: 1975001828@qq.com
License: UNKNOWN
Location: /usr/lib/python2.7/site-packages
Requires:

$ python -V
Python 2.7.10

$ echo $PYTHONPATH
:/usr/lib/python2.7/site-packages

$ python -c "import sys; print sys.path"
['', '/usr/lib/python2.7/site-packages/pydns-2.3.6-py2.7.egg', '/usr/lib/python2.7/site-packages/xmltodict-0.10.2-py2.7.egg', '/usr/lib/python2.7/site-packages/spambayes-1.1b1-py2.7.egg', '/usr/lib/python2.7/site-packages/pydns-2.3.6-py2.7.egg', '/usr/lib/python2.7/site-packages/lockfile-0.11.0-py2.7.egg', '/usr/lib/python2.7/site-packages/FinancialFundamentals-0.2.3-py2.7.egg', '/usr/lib/python2.7/site-packages/vector_cache-0.1.0-py2.7.egg', '/usr/lib/python2.7/site-packages/python_dateutil-1.5-py2.7.egg', '/usr/lib/python2.7/site-packages/blist-1.3.6-py2.7-cygwin-2.5.2-i686.egg', '/usr/lib/python2.7/site-packages/xmltodict-0.10.2-py2.7.egg', '/usr/lib/python2.7/site-packages/buildozer-0.33.dev0-py2.7.egg', '/home/Administrator/python/scrapping/guru_steve_avon', '/usr/lib/python2.7/site-packages', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-cygwin', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/Administrator/.local/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/PIL', '/usr/lib/python2.7/site-packages/gst-0.10', '/usr/lib/python2.7/site-packages/gtk-2.0']

有什么建议可以让news被识别?


编辑1,回复@JacobIRR:

已安装

news - 没有投诉 - 使用pip(见下文),但 site-packages 中似乎没有news子目录

$ ls -lsad  /usr/lib/python2.7/site-packages/n*
 0 drwxr-xr-x+ 1 Administrator None   0 Jun  4  2015 /usr/lib/python2.7/site-packages/ndg
 1 -rw-r--r--  1 Administrator None 297 Jun  4  2015 /usr/lib/python2.7/site-packages/ndg_httpsclient-0.4.0-py2.7-nspkg.pth
 4 drwxr-xr-x+ 1 Administrator None   0 Jun  4  2015 /usr/lib/python2.7/site-packages/ndg_httpsclient-0.4.0-py2.7.egg-info
 4 drwxr-xr-x+ 1 Administrator None   0 Feb 25  2016 /usr/lib/python2.7/site-packages/netsnmp
 4 drwxr-xr-x+ 1 Administrator None   0 Feb 25  2016 /usr/lib/python2.7/site-packages/netsnmp_python-1.0a1-py2.7.egg-info
 4 drwxr-xr-x+ 1 Administrator None   0 Apr 26  2016 /usr/lib/python2.7/site-packages/networkx
 4 drwxr-xr-x+ 1 Administrator None   0 Apr 26  2016 /usr/lib/python2.7/site-packages/networkx-1.11.dist-info
 4 drwxr-xr-x+ 1 Administrator None   0 Apr  8 21:28 /usr/lib/python2.7/site-packages/news-1.0.dist-info
 1 -rw-r--r--  1 Administrator None 154 Apr  8 21:28 /usr/lib/python2.7/site-packages/news_module.py
 1 -rw-r--r--  1 Administrator None 457 Apr  8 21:28 /usr/lib/python2.7/site-packages/news_module.pyc
12 drwxr-xr-x+ 1 Administrator None   0 Sep 27  2015 /usr/lib/python2.7/site-packages/nltk
 4 drwxr-xr-x+ 1 Administrator None   0 Sep 27  2015 /usr/lib/python2.7/site-packages/nltk-3.0.5-py2.7.egg-info
 0 drwxr-xr-x+ 1 Administrator None   0 Apr 13  2015 /usr/lib/python2.7/site-packages/numba
 0 drwxr-xr-x+ 1 Administrator None   0 Apr 13  2015 /usr/lib/python2.7/site-packages/numba-0.18.2-py2.7.egg-info
 0 drwxr-xr-x+ 1 Administrator None   0 Feb 25  2016 /usr/lib/python2.7/site-packages/numpy
 0 drwxr-xr-x+ 1 Administrator None   0 Apr 26  2016 /usr/lib/python2.7/site-packages/numpy-1.11.0.dist-info
 0 drwxr-xr-x+ 1 Administrator None   0 Apr  9  2015 /usr/lib/python2.7/site-packages/numpy-1.9.2-py2.7.egg-infoold-1
 0 drwxr-xr-x+ 1 Administrator None   0 Jun 18  2015 /usr/lib/python2.7/site-packages/numpy-1.9.2-py2.7.egg-infoold-2

$ pip uninstall news
Uninstalling news-1.0:
  /usr/lib/python2.7/site-packages/news-1.0.dist-info/DESCRIPTION.rst
  /usr/lib/python2.7/site-packages/news-1.0.dist-info/INSTALLER
  /usr/lib/python2.7/site-packages/news-1.0.dist-info/METADATA
  /usr/lib/python2.7/site-packages/news-1.0.dist-info/RECORD
  /usr/lib/python2.7/site-packages/news-1.0.dist-info/WHEEL
  /usr/lib/python2.7/site-packages/news-1.0.dist-info/metadata.json
  /usr/lib/python2.7/site-packages/news-1.0.dist-info/top_level.txt
  /usr/lib/python2.7/site-packages/news_module.py
  /usr/lib/python2.7/site-packages/news_module.pyc
Proceed (y/n)? y
  Successfully uninstalled news-1.0

$ pip install news
Collecting news
Installing collected packages: news
Successfully installed news-1.0

1 个答案:

答案 0 :(得分:1)

好吧,我从pypi下载了模块,看看里面有什么。 news-1.0.zip只有一个名为height = auto的文件,其中包含一个方法<a href="/Home/Index" class="navbar-brand myLogo"> <img src="~/Content/images/logo.png" alt="Company logo" height="50"/> </a> .myLogo{ height:auto; }

所以,你应该试试

news_module.py

问:您是否正在寻找newspaper模块?