我正在构建自己的Python模块,只是为了了解它的工作原理。我的Python很不错,但我以前从未构建或提交任何包。
我跟着Python Hosted以及the official setuptools
documentation的指南和python.org上的这篇文章。但是,我仍然无法让这个工作。
包结构有三个模块(FileHelpers,TypeHelpers,XmlHelpers),如下所示:
PyLT3/
|- .git/
|- .idea/
|- setup.py
|- __init__.py
|- README.rst
|- LICENSE.txt
|- .gitignore
|- FileHelpers.py
|- TypeHelpers.py
|- XmlHelpers.py
setup.py
的内容:
from setuptools import setup, find_packages
setup(
name='PyLT3',
version='0.1.3',
description='A collection of helper functions and NLP scripts',
long_description='During my time working on the PhD project PreDict, I have written and gathered a bunch of useful functions. They are collected here as part of the PyLT3 package.',
keywords='nlp xml file-handling helpers',
packages=find_packages(),
url='https://github.com/BramVanroy/PyLT3',
author='Bram Vanroy',
author_email='bramvanroy@hotmail.com',
license='MIT',
classifiers=[
'Development Status :: 1 - Planning',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'Topic :: Text Processing',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.6',
],
project_urls = {
'Bug Reports': 'https://github.com/BramVanroy/PyLT3/issues',
'Source': 'https://github.com/BramVanroy/PyLT3',
},
python_requires='>=3.6',
)
MANIFEST.in的内容:
prune .idea/*
有了这些数据,我创建了一个发行版:
python setup.py sdist
和一个轮子:
python setup.py bdist_wheel
然后将分发上传到PyPi:
twine upload dist/*
为了测试这个,我用pip下载the package:
pip install PyLT3
(也使用pip3
。)它成功安装。
但是,当我尝试一个简单的import PyLT3
时,我收到一个错误
import PyLT3
ModuleNotFoundError:没有名为'PyLT3'的模块
这很奇怪,因为pip告诉我模块已成功安装。所以我去寻找模块,它的*.info
安装在C:PythonPython36Libsite-packagesPyLT3-0.1.3.dist-info
。但我假设这不是实际的包,而只是一个信息目录。没有其他包(例如PyLT3/
)。
所有这一切都让我相信我在包装时做错了。我忘记了什么?