Search code examples
pythonpython-3.xpackagingpypi

Created a python package in TestPypi but I can't import it


I've deployed my first package in test.pypi.org as you can find it here

I have installed my package in my virtual environment (.venv).

$ pip list

returns :

Package    Version
---------- -------
pip        20.1
pyupurs    0.0.2
setuptools 46.0.0
wheel      0.34.2

But as you can see here, I cannot import it within my interpreter.

Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyupurs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyupurs'

Why is this happening? How can I fix it?


Solution

  • In your package pyupurs there is nothing that can be imported under same name. The distribution package pyupurs installs top-level importable package named stateless_file_ops. So you can only do

    import stateless_file_ops
    

    If you want to change that you need to change you subdirectory structure perhaps adding a directory pyupurs with file __init__.py in it.