4

我在 ex48\ex48\game.py 中有一个 game.py,在 ex48\docs\setup.py 中有我的 setup.py,我在 ex48\ex48__init.py 和 ex48\tests__init__.py 中有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

这是我的文件结构的图片:文件结构

为什么我会收到此错误?

============================编辑====================== ========= 我将安装文件放在根文件夹而不是文档中,如下所示。然后我尝试再次安装,并得到了这个:

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

所以有些东西不起作用,但我不确定是什么。

4

0 回答 0