我有一个非常简单的项目示例,我无法开始工作。
我有一个看起来像这样的setup.py:
from setuptools import setup
install_requires=['numpy','matplotlib','pyusb']
setup(
name='TestInstall',
version='1.0',
description='a test',
author='Pete',
author_email='pete@hotmail.com',
url='https://github.com',
packages=['App'],
install_requires=install_requires,
entry_points={
'console_scripts': [
'TestInstall = App.Test:main']}
)
我有一个目录电话'应用程序'在这个目录中,我有两个文件:
。__ INIT __ PY:
import Test
和Test.py:
def main():
print 'Hi There'
if __name__ == '__main__':
main()
我运行' python setup.py install',这似乎运行得很好:
sudo -H python setup.py install
[sudo] password for pete:
running install
running bdist_egg
running egg_info
creating TestInstall.egg-info
writing requirements to TestInstall.egg-info/requires.txt
writing TestInstall.egg-info/PKG-INFO
writing top-level names to TestInstall.egg-info/top_level.txt
writing dependency_links to TestInstall.egg-info/dependency_links.txt
writing entry points to TestInstall.egg-info/entry_points.txt
writing manifest file 'TestInstall.egg-info/SOURCES.txt'
reading manifest file 'TestInstall.egg-info/SOURCES.txt'
writing manifest file 'TestInstall.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-i686/egg
running install_lib
running build_py
creating build
creating build/lib.linux-i686-2.7
creating build/lib.linux-i686-2.7/App
copying App/Test.py -> build/lib.linux-i686-2.7/App
copying App/__init__.py -> build/lib.linux-i686-2.7/App
creating build/bdist.linux-i686
creating build/bdist.linux-i686/egg
creating build/bdist.linux-i686/egg/App
copying build/lib.linux-i686-2.7/App/Test.py -> build/bdist.linux-i686/egg/App
copying build/lib.linux-i686-2.7/App/__init__.py -> build/bdist.linux-i686/egg/App
byte-compiling build/bdist.linux-i686/egg/App/Test.py to Test.pyc
byte-compiling build/bdist.linux-i686/egg/App/__init__.py to __init__.pyc
creating build/bdist.linux-i686/egg/EGG-INFO
copying TestInstall.egg-info/PKG-INFO -> build/bdist.linux-i686/egg/EGG-INFO
copying TestInstall.egg-info/SOURCES.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying TestInstall.egg-info/dependency_links.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying TestInstall.egg-info/entry_points.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying TestInstall.egg-info/requires.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying TestInstall.egg-info/top_level.txt -> build/bdist.linux-i686/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/TestInstall-1.0-py2.7.egg' and adding 'build/bdist.linux-i686/egg' to it
removing 'build/bdist.linux-i686/egg' (and everything under it)
Processing TestInstall-1.0-py2.7.egg
Copying TestInstall-1.0-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Adding TestInstall 1.0 to easy-install.pth file
Installing TestInstall script to /usr/local/bin
Installed /usr/local/lib/python2.7/dist-packages/TestInstall-1.0-py2.7.egg
Processing dependencies for TestInstall==1.0
Searching for pyusb==1.0.0
Best match: pyusb 1.0.0
Adding pyusb 1.0.0 to easy-install.pth file
Using /usr/local/lib/python2.7/dist-packages
Searching for matplotlib==1.5.1
Best match: matplotlib 1.5.1
matplotlib 1.5.1 is already the active version in easy-install.pth
Using /usr/lib/python2.7/dist-packages
Searching for numpy==1.11.0
Best match: numpy 1.11.0
numpy 1.11.0 is already the active version in easy-install.pth
Using /usr/lib/python2.7/dist-packages
Finished processing dependencies for TestInstall==1.0
pete@pete-ThinkPad-T60p:~/Work/TestInstall$
但是当我尝试运行该程序时:
TestInstall
我明白了:
pete@pete-ThinkPad-T60p:~/Work/TestInstall$ TestInstall
Traceback (most recent call last):
File "/usr/local/bin/TestInstall", line 9, in <module>
load_entry_point('TestInstall==1.0', 'console_scripts', 'TestInstall')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named Test
pete@pete-ThinkPad-T60p:~/Work/TestInstall$
这一定是一个简单的错误,但我到处寻找并拔掉了我的头发。
提前感谢您的回答。 皮特
BTW,我在/usr/local/lib/python2.7/dist-packages中看到了.egg文件,在其中,我看到了EGG-INFO列出了列出的来源,入口点等,以及App目录,在它下面,我的__init__.py和.pyc文件以及我的Test.py和.pyc文件。