Search code examples
pythonpython-3.xgitpippypi

Pip install and run git repo


I'm trying to pip install a separate git repo into my python project. Pip install seems to work when I run pip install git+https://github.com/XxdpavelxX/myapp. However when I then run my code I get the following error.

Here's my app: https://github.com/XxdpavelxX/myapp

ModuleNotFoundError: No module named 'myapp'
ERROR: could not load /Users/myUser/stuff/callerFile.py

Here's the callerFile.py (in a separate git repo):

from myapp import test
print test.random_print()

I suspect that this is pip install related. When I run pip install git+https://github.com/XxdpavelxX/myapp it seems to pass, however inside of my python venv/lib/python3.7/site-packages I only see myapp-1.0py3.7.eggs-info instead of the actual package. Anyone knowing what I'm doing wrong? Do I need to add my library to pypi for this to work?

Edit: Added the actual url to github repo I'm testing.


Solution

  • Create a folder called myapp and move the __init__.py and test.py files to that folder.

    enter image description here

    Add the following line to your setup.py (I added after url),

    packages=['myapp'],
    

    Now installation will be successful and you can import your package.

    What is setup.py?