当我使用pip install beautifulsoup时,为什么只有egg-info没有实际的模块?

时间:2014-04-04 12:54:35

标签: python beautifulsoup pip egg

我使用命令pip install beautifulsoup4来安装beautifulsoup,但是,在我尝试导入它之后失败了,我发现了一些有趣的东西,只有egg-info文件夹但没有脚本文件夹,有人可以告诉我为什么以及如何解决这个问题?我知道我可以获取脚本并将其移动到sitepackages文件夹,我确实喜欢它并且它有效,但我觉得这是个坏主意。

1 个答案:

答案 0 :(得分:5)

使用beautifulsoup4安装pip时,您将按该名称安装发行版.egg-info文件夹pip在安装时创建该分发以分发命名(加上版本和python体系结构)。

该发行版包含一个或多个软件包或模块,这些软件包或模块安装在site-packages文件夹 next 中的.egg-info目录中。这些包或模块的名称不一定与分发名称相对应。

对于BeautifulSoup 4,发行版包含一个名为bs4的包。

您可以自己验证; .egg-info目录中有一个名为installed-files.txt的文件,列出了所有相关文件(使用相对路径):

$ cat lib/python2.7/site-packages/beautifulsoup4*.egg-info/installed-files.txt
../bs4/__init__.py
../bs4/dammit.py
../bs4/diagnose.py
../bs4/element.py
../bs4/testing.py
../bs4/builder/__init__.py
../bs4/builder/_html5lib.py
../bs4/builder/_htmlparser.py
../bs4/builder/_lxml.py
../bs4/tests/__init__.py
../bs4/tests/test_builder_registry.py
../bs4/tests/test_docs.py
../bs4/tests/test_html5lib.py
../bs4/tests/test_htmlparser.py
../bs4/tests/test_lxml.py
../bs4/tests/test_soup.py
../bs4/tests/test_tree.py
../bs4/__init__.pyc
../bs4/dammit.pyc
../bs4/diagnose.pyc
../bs4/element.pyc
../bs4/testing.pyc
../bs4/builder/__init__.pyc
../bs4/builder/_html5lib.pyc
../bs4/builder/_htmlparser.pyc
../bs4/builder/_lxml.pyc
../bs4/tests/__init__.pyc
../bs4/tests/test_builder_registry.pyc
../bs4/tests/test_docs.pyc
../bs4/tests/test_html5lib.pyc
../bs4/tests/test_htmlparser.pyc
../bs4/tests/test_lxml.pyc
../bs4/tests/test_soup.pyc
../bs4/tests/test_tree.pyc
./
dependency_links.txt
PKG-INFO
SOURCES.txt
top_level.txt
相关问题