我正在尝试在python上安装报纸模块,但是我不断收到错误消息,说没有这样的模块。
我已尝试确保将目录设置在正确的位置,并且已检查模块是否已安装。我正在使用的PyCharm会在我检查时显示它已安装。为什么当我明确已经安装了模块时却说没有模块?
Alexs-MacBook-Pro:~ alexfrandsen14$ pip3 install newspaper3k
Requirement already satisfied: newspaper3k in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (0.2.8)
Requirement already satisfied: jieba3k>=0.35.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (0.35.1)
Requirement already satisfied: lxml>=3.6.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (4.3.0)
Requirement already satisfied: python-dateutil>=2.5.3 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (2.7.5)
Requirement already satisfied: requests>=2.10.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests-2.18.1-py3.7.egg (from newspaper3k) (2.18.1)
Requirement already satisfied: Pillow>=3.3.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (5.4.1)
Requirement already satisfied: feedfinder2>=0.0.4 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (0.0.4)
Requirement already satisfied: cssselect>=0.9.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (1.0.3)
Requirement already satisfied: beautifulsoup4>=4.4.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beautifulsoup4-4.6.0-py3.7.egg (from newspaper3k) (4.6.0)
Requirement already satisfied: feedparser>=5.2.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (5.2.1)
Requirement already satisfied: tldextract>=2.0.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (2.2.0)
Requirement already satisfied: PyYAML>=3.11 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (3.13)
Requirement already satisfied: tinysegmenter==0.3 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (0.3)
Requirement already satisfied: nltk>=3.2.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from newspaper3k) (3.4)
Requirement already satisfied: six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from python-dateutil>=2.5.3->newspaper3k) (1.12.0)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/certifi-2018.10.15-py3.7.egg (from requests>=2.10.0->newspaper3k) (2018.10.15)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chardet-3.0.4-py3.7.egg (from requests>=2.10.0->newspaper3k) (3.0.4)
Requirement already satisfied: idna<2.6,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/idna-2.5-py3.7.egg (from requests>=2.10.0->newspaper3k) (2.5)
Requirement already satisfied: urllib3<1.22,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3-1.21.1-py3.7.egg (from requests>=2.10.0->newspaper3k) (1.21.1)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from tldextract>=2.0.1->newspaper3k) (39.0.1)
Requirement already satisfied: requests-file>=1.4 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from tldextract>=2.0.1->newspaper3k) (1.4.3)
Requirement already satisfied: singledispatch in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from nltk>=3.2.1->newspaper3k) (3.4.0.3)
Alexs-MacBook-Pro:~ alexfrandsen14$ python3
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import newspaper3k
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'newspaper3k'
>>>
答案 0 :(得分:2)
它可以作为newspaper
导入:
import newspaper
(PyPI名称并不总是与包名称对齐。)
>>> import newspaper
>>> newspaper.__version__
'0.2.7'
从shell:
$ pip list | grep newspaper
newspaper3k 0.2.7
更具体地说,newspaper3k
中定义了名称setup.py
。不一定必须在文件级别匹配顶级程序包名称。