1

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.

dredbound
  • 1,579
  • 3
  • 17
  • 27

3 Answers3

2

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?

Manoj Mohan
  • 5,654
  • 1
  • 17
  • 21
1

You don't need to post your code to pypi. I suggest you to use tag #egg to set package name. So the pip status would be like

pip install git+https://github.com/myGitUser/myLibrary#egg=myLibrary

Leo_Liu_MJ
  • 179
  • 1
  • 4
  • furthermore you can add `--process-dependency-links` on the back to process boto3 and selenium as well. – d_kennetz Mar 12 '19 at 15:35
  • Still getting the same error. I modified the question and included the actual github repo so it's easier to debug – dredbound Mar 12 '19 at 15:45
1

Your package has neither py_modules nor packages hence it doesn't install anything importable when installed.

My advice is to rename your __init__.py to myapp.py and add this to setup.py:

setup(
    …
    py_modules=['myapp'],
    …
)
phd
  • 82,685
  • 13
  • 120
  • 165