Pip-installed module cannot be imported

I uploaded my first PyPi package today. It took me a while to figure everything out, but I did it, and now I’m trying to import it to another project of mine.

Unfortunately I get a ModuleNotFoundError. I’m on Windows 10, running python 3.9.6. I’ve tried everything I’ve seen on the internet, deleted the venv and recreated it, reuploaded the package to PyPi, installed it with python -m pip install sqlcontroller and even with ./venv/Scripts/python.exe -m pip install sqlcontroller. I’ll try to supply all the info I can below.

The PyPi package: https://pypi.org/project/sqlcontroller/

On Github: https://github.com/RedKnight91/sqlcontroller

(venv) PS C:UsersmikecDocumentsPythonbinance-trading-bot-evaluator> python -m pip install sqlcontroller --no-cache-dir --upgrade 
Requirement already satisfied: sqlcontroller in c:usersmikecdocumentspythonbinance-trading-bot-evaluatorvenvlibsite-packages (0.0.2)

import sqlcontroller results in:

Traceback (most recent call last):
  File "c:UsersmikecDocumentsPythonbinance-trading-bot-evaluatorsrcmain.py", line 2, in <module>
    from sqlcontroller import SqlController
ModuleNotFoundError: No module named 'sqlcontroller'

pip show output

(venv) PS C:UsersmikecDocumentsPythonbinance-trading-bot-evaluator> python -m pip show sqlcontroller --files
Name: sqlcontroller
Version: 0.0.2
Summary: Controller class to handle sqlite3 databases.
Home-page: https://github.com/RedKnight91/sqlcontroller
Author: Michael Cazzarolli
Author-email: mikecazzarolli@gmail.com
License: UNKNOWN
Location: c:usersmikecdocumentspythonbinance-trading-bot-evaluatorvenvlibsite-packages
Requires:
Required-by:
Files:
  sqlcontroller-0.0.2.dist-infoINSTALLER
  sqlcontroller-0.0.2.dist-infoLICENSE
  sqlcontroller-0.0.2.dist-infoMETADATA
  sqlcontroller-0.0.2.dist-infoRECORD
  sqlcontroller-0.0.2.dist-infoREQUESTED
  sqlcontroller-0.0.2.dist-infoWHEEL
  sqlcontroller-0.0.2.dist-infotop_level.txt
  src__init__.py
  src__pycache____init__.cpython-39.pyc
  src__pycache__sqlcontroller.cpython-39.pyc
  srcsqlcontroller.py
  tests__init__.py
  tests__pycache____init__.cpython-39.pyc
  tests__pycache__conftest.cpython-39.pyc
  tests__pycache__test_sqlcontroller.cpython-39.pyc
  testsconftest.py
  teststest_sqlcontroller.py

where python gives no output from venv:

(venv) PS C:UsersmikecDocumentsPythonbinance-trading-bot-evaluator> where python
(venv) PS C:UsersmikecDocumentsPythonbinance-trading-bot-evaluator> 

but it does from outside:

C:Usersmikec>where python
C:UsersmikecAppDataLocalProgramsPythonPython39python.exe

pip freeze

(venv) PS C:UsersmikecDocumentsPythonbinance-trading-bot-evaluator> pip freeze
sqlcontroller==0.0.2

Answer

You have a wrong file structure

This is an example how my package looks

(venv) PS D:Pythonthebot> pip show bdbf --files
Name: bdbf
Author: Bertik23
Author-email: bertikxxiii@gmail.com
License: UNKNOWN
Location: d:pythonthebotvenvlibsite-packages
Requires: discord.py
Required-by:
Files:
  bdbf-1.1.2.dist-infoINSTALLER
  bdbf-1.1.2.dist-infoLICENSE
  bdbf-1.1.2.dist-infoMETADATA
  bdbf-1.1.2.dist-infotop_level.txt
  bdbf__init__.py
  bdbf__pycache____init__.cpython-39.pyc
  bdbf__pycache__bdbf.cpython-39.pyc
  bdbf__pycache__exceptions.cpython-39.pyc
  bdbf__pycache__functions.cpython-39.pyc
  bdbf__pycache__main.cpython-39.pyc
  bdbfbdbf.py
  bdbfexceptions.py
  bdbffunctions.py
  bdbfmain.py

As you can see, all of the .py filles are in the bdbf folder, but yours are in src, that is than the name you have to import, so if you do import src you probably would import your package