我已经在test.pypi中创建了我的第一个python包(在python3.7.1中开发,有关更多详细信息:https://github.com/BatLabLancaster/preparenovonix): https://test.pypi.org/project/preparenovonix/
可以通过以下方式正确安装:python3 -m pip
但是,当我尝试导入程序包时,出现错误消息。
我尝试在Windows和Linux中安装该软件包。我还使用了带有ubuntu和python3.6的Docker容器。在所有3个环境中,我都尝试安装成功。对于安装,我遵循了https://packaging.python.org/tutorials/packaging-projects/中的描述。下面显示了安装命令和在docker + ubuntu中收到的消息(Windows中类似的消息):
$ python3 -m pip install -i https://test.pypi.org/simple/ --user preparenovonix
Collecting preparenovonix
Using cached https://test-files.pythonhosted.org/packages/1b/b2/97dd3a537bae2b9605c5e1435c49ac644946b10adf41dc904dee2f1d45e4/preparenovonix-0.0.1-py3-none-any.whl
Installing collected packages: preparenovonix
Successfully installed preparenovonix-0.0.1
这是导入时收到的错误消息:
# python3 -i
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import preparenovonix
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'preparenovonix'
我希望python能够成功安装该软件包,并且在使用pip show时也会显示该软件包。
答案 0 :(得分:1)
我认为程序包结构有问题。我尝试了您的“ example.py”,它成功了。
D:\preparenovonix>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycode.novonix_add
>>>