【发布时间】:2021-10-31 07:26:03
【问题描述】:
我正在尝试制作一个 python 包。这是我的包结构。
my-package
├── README.md
├── LICENSE
├── .gitignore
├── setup.py
└── my-package
├── __init__.py
└── other_files.py
在我的setup.py:
import io
import os
from setuptools import setup, find_packages, find_namespace_packages
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name="new-package", # This is the name of the package
version="1.0.0", # The initial release version
author="Author Name", # Full name of the author
author_email='author@gmail.com',
url='https://github.com/Author/myPackage',
description="Short Descriptio",
long_description=long_description, # Long description read from the the readme file
long_description_content_type="text/markdown",
packages=find_namespace_packages(), # List of all python modules to be installed
classifiers=[
'Intended Audience :: Developers',
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
'Topic :: Software Development :: Internationalization',
], # Information to filter the project on PyPi website
python_requires='>=3.5', # Minimum version requirement of the package
install_requires=['requests','simplejson'], # Install other dependencies if any
)
从根目录,我使用这个命令生成分发文件:
python setup.py sdist bdist_wheel
然后,我使用此命令从包根目录在虚拟环境中安装此包:
python -m pip install -e .
安装后,如果我运行pip list,它显示这个包(new_package)已安装。
但是当我尝试使用import new_package 导入它时,它给了我
ModuleNotFoundError: No module named 'new_package'
我在堆栈中搜索过类似的问题,但无法解决。
有什么帮助吗?
【问题讨论】:
标签: python pip setuptools setup.py