我在ex48 \ ex48 \ game.py中有一个game.py,在ex48 \ docs \ setup.py中有我的setup.py,我在ex48中都有 init .py \ ex48__init.py和ex48 \ tests__init __。py。 Game.py包含以下代码:
class lexicon(object):
def __init__(self):
pass
def lexicon(self):
pass
setup.py包含以下代码:
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
config = {
'description': 'ex48',
'author': 'My Name',
'url': 'URL to get it at.',
'download_url': 'Where to download it.',
'author_email': 'My email',
'version': '0.1',
'install_requires': ['nose'],
'packages': ['ex48'],
'scripts': [],
'name': 'ex48'
}
setup(**config)
当我运行python -m setup.py sdist
时,我收到以下消息:
PS C:\python\projects\ex48\docs> python -m setup.py sdist
running sdist
running egg_info
writing requirements to ex48.egg-info\requires.txt
writing ex48.egg-info\PKG-INFO
writing top-level names to ex48.egg-info\top_level.txt
writing dependency_links to ex48.egg-info\dependency_links.txt
warning: manifest_maker: standard file '-c' not found
error: package directory 'ex48' does not exist
为什么我收到此错误?
=========================== EDIT =================== ============ 我将安装文件放在根文件夹中而不是文档中,如下所示。然后我再次尝试安装,并得到了这个:
PS C:\python\projects\ex48> python -m setup.py sdist
running sdist
running egg_info
writing requirements to ex48.egg-info\requires.txt
writing ex48.egg-info\PKG-INFO
writing top-level names to ex48.egg-info\top_level.txt
writing dependency_links to ex48.egg-info\dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'ex48.egg-info\SOURCES.txt'
writing manifest file 'ex48.egg-info\SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt
running check
creating ex48-0.1
creating ex48-0.1\ex48
creating ex48-0.1\ex48.egg-info
copying files to ex48-0.1...
copying ex48\__init__.py -> ex48-0.1\ex48
copying ex48\game.py -> ex48-0.1\ex48
copying ex48.egg-info\PKG-INFO -> ex48-0.1\ex48.egg-info
copying ex48.egg-info\SOURCES.txt -> ex48-0.1\ex48.egg-info
copying ex48.egg-info\dependency_links.txt -> ex48-0.1\ex48.egg-info
copying ex48.egg-info\requires.txt -> ex48-0.1\ex48.egg-info
copying ex48.egg-info\top_level.txt -> ex48-0.1\ex48.egg-info
Writing ex48-0.1\setup.cfg
Creating tar archive
removing 'ex48-0.1' (and everything under it)
C:\Python27\python.exe: No module named setup.py
所以我收到两条关于未找到文件的警告,当我尝试从另一个脚本中的游戏文件导入模块时,我得到:
PS C:\python\projects\ex48> python tests\ex48_tests.py
Traceback (most recent call last):
File "tests\ex48_tests.py", line 1, in <module>
from ex48.game import lexicon
ImportError: No module named game
所以有些东西不起作用,但我不确定是什么。