【发布时间】:2017-12-17 23:18:12
【问题描述】:
使用 Python 3.5
我有这个结构
someCode/
someCode/
A.py
__init__.py
setup.py
README.md
LICENSE
MANIFEST.rst
someSubDir/
B.py
__init__.py
A.py 使用
导入一些 B.py 类from someSubDir.B import someClass
当我运行我的 python 脚本时,这非常有效。
我使用 wheel 将其打包并将 wheel dist 安装到不同的 conda 环境中。这就是问题所在 当我尝试使用
导入模块时import someCode.A as A
ImportError: No module named 'someSubDir.B'
似乎 python 解释器正在环境中寻找一个名为 someSubDir 的模块,但我希望它在 someCode 模块中查找以找出答案。
我哪里错了?
更新 这就是我的 setup.py 的样子
from setuptools import setup, find_packages
ver = "9.9.9"
with open("README.md", mode='r') as f:
long_description = f.read()
setup(
name='someCode',
version=ver,
url='https://github.com/something',
description='something else',
long_description=long_description,
license='GNU',
author='someone',
author_email='something@gmail.com',
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Programming Language :: Python :: 3.5",
],
keywords='operations',
packages=find_packages(),
install_requires=[],
python_requires='~=3.5'
)
【问题讨论】:
-
确认
someSubDir/B.py已安装。向我们展示您的setup.py。 -
我该怎么做?
-
将 setup.py 添加到原始问题中
-
想通了。下面贴出答案。谢谢你的帮助。它让我思考更多
标签: python python-3.x release pypi