pythonpippypipythoninterpreter

I have uploaded a Python package in pip, then pip installed this package, but I can't import this package in Python Interpreter


I have just uploaded a Python package into pip called hqc:

https://pypi.org/project/hqc/0.0.1/

then successfully pip installed the package using:

pip install hqc

pip install hqc but I can't seem to import the package in Python Interpreter. When I do this, I get the following error message:

>>> import hqc
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import hqc
ModuleNotFoundError: No module named 'hqc'

What am I missing? Do I need to set the environment variable PATH or is it something else?


Solution

  • In the folder where setup.py is, make a folder called hqc and put an empty file called __init__.py (thats two underscores on each side). Right now, there's no file to import so python fails when importing it.

    hqc-0.0.1:

    enter image description here

    hqc:

    enter image description here

    You can test the package by going to the directory where setup.py is and running

    pip install .
    

    Before trying again, be sure to uninstall

    pip uninstall hqc