为什么我的setup.py生成的脚本找不到我安装的模块?

时间:2014-06-05 18:16:29

标签: python python-2.7 setuptools

编辑:确切的代码位于https://github.com/edbrannin/mkdocs/tree/windows-runnable的GitHub上,而且在Linux上也失败了。


我尝试使用entry_points的{​​{1}}参数为mkdocs跨平台安装脚本:

setup()

The output from python setup.py install is here.

正在 entry_points={ 'console_scripts': [ 'mkdocs = mkdocs.mkdocs:main_entry_point', ], }, 生成python setup.py install并在c:\Python27\lib\site-packages\mkdocs中生成此文件:

c:\Python27\Scripts\mkdocs-script.py

当我尝试运行mkdocs时,它说它无法找到模块:

#!C:\Python27\python.exe # EASY-INSTALL-ENTRY-SCRIPT: 'mkdocs==0.9','console_scripts','mkdocs' __requires__ = 'mkdocs==0.9' import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.exit( load_entry_point('mkdocs==0.9', 'console_scripts', 'mkdocs')() )

......但它显然在那里:


C:\>mkdocs
Traceback (most recent call last):
  File "C:\Python27\Scripts\mkdocs-script.py", line 9, in <module>
    load_entry_point('mkdocs==0.9', 'console_scripts', 'mkdocs')()
  File "C:\Python27\lib\site-packages\distribute-0.6.34-py2.7.egg\pkg_resources.py", line 343, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "C:\Python27\lib\site-packages\distribute-0.6.34-py2.7.egg\pkg_resources.py", line 2307, in load_entry_point
    return ep.load()
  File "C:\Python27\lib\site-packages\distribute-0.6.34-py2.7.egg\pkg_resources.py", line 2013, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
ImportError: No module named mkdocs

知道我做错了吗?

1 个答案:

答案 0 :(得分:2)

您的脚本位置确实不存在。你的setup.py指定了mkdocs.mkdocs。 main_entry_point,但不可导入。你可以在你的python shell中检查这个:

>>> from mkdocs.mkdocs import main_entry_point

这将导致导入错误。发生这种情况是因为文件命名错误:如果将mkdocs / mkdocs重命名为mkdocs / mkdocs.py,您应该会看到事情开始起作用。