【发布时间】:2017-01-09 20:34:30
【问题描述】:
我无法在我的 python 包中导入入口点控制台脚本。寻求帮助调试我当前的问题,因为我已阅读有关该问题的所有相关帖子。
这是我的目录结构:
├── ContentAnalysis
│ ├── __init__.py
│ ├── command_line.py
│ ├── document.py
│ ├── entities.py
│ ├── sentiment.py
│ ├── summary.py
│ ├── text_tokenize.py
│ ├── tokens.py
├── local-requirements.txt
├── requirements.txt
├── server-requirements.txt
├── setup.py
└── tests
├── tests.py
└── tests.pyc
这是我的 setup.py 的样子
from setuptools import setup
config = {
'description': 'Tools to extract information from web links',
'author': 'sample',
'version': '0.1',
'install_requires': ['nose'],
'packages': ['ContentAnalysis'],
'entry_points': {
'console_scripts': ['content_analysis=ContentAnalysis.command_line:main'],
},
'name':'ContentAnalysis',
'include_package_data':True
}
setup(**config)
我已经安装了该软件包并验证了 content_analysis 可以从命令行访问。我还验证了我的 ContentAnalysis 包可以从计算机中任何 cd 的 python 解释器导入。但是我仍然收到“执行时未找到入口点错误”
grant@DevBox2:/opt/content-analysis$ content_analysis -l 'http://101beauty.org/how-to-use-baking-soda-to-reduce-dark-circles-and-bags-under-the-eyes/'
Traceback (most recent call last):
File "/opt/anaconda2/bin/content_analysis", line 11, in <module>
load_entry_point('ContentAnalysis==0.1', 'console_scripts', 'content_analysis')()
File "/opt/anaconda2/lib/python2.7/site-packages/setuptools-26.1.1-py2.7.egg/pkg_resources/__init__.py", line 565, in load_entry_point
File "/opt/anaconda2/lib/python2.7/site-packages/setuptools-26.1.1-py2.7.egg/pkg_resources/__init__.py", line 2588, in load_entry_point
ImportError: Entry point ('console_scripts', 'content_analysis') not found
感谢任何有关调试的帮助或提示
编辑#1:
尝试调试问题时,我注意到命令行无法作为 ContentAnalysis 中的子模块访问
>>> import ContentAnalysis
>>> ContentAnalysis.tokens
<module 'ContentAnalysis.tokens' from '/opt/anaconda2/lib/python2.7/site-packages/ContentAnalysis/tokens.pyc'>
>>> ContentAnalysis.command_line
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'command_line'
>>>
似乎没有将 command_line 添加到相关的 site_packages 文件夹中。
grant@DevBox2:/opt/anaconda2/lib/python2.7/site-packages/ContentAnalysis$ ls
data entities.py __init__.pyc summary.py text_tokenize.pyc
document.py entities.pyc sentiment.py summary.pyc tokens.py
document.pyc __init__.py sentiment.pyc text_tokenize.py tokens.pyc
不知道为什么?
【问题讨论】:
-
可能权限被拒绝
标签: python debian anaconda setuptools setup.py