Reputation: 5246
I'm new to python and trying to test a script from this github repo (https://github.com/mgp25/psn-api).
The root directory has an example.py
and I'm trying to run it with
$ python example.py
which gives this error:
Traceback (most recent call last):
File "example.py", line 1, in <module>
from src.Auth import Auth
ImportError: No module named src.Auth
How can I get this to run?
There is a folder in the root directory named src but because I'm new to python I don't know how to connect things so that the src.Auth
module gets imported (or if that's even the right terminology)
Upvotes: 0
Views: 145
Reputation: 105
Being in the repository root directory, you do:
touch src/__init__.py
This will create an empty file but it is necessary for the Python module search system. Then you should be able to run it without problems, unless there is some dependency on external libraries.
Upvotes: 1
Reputation: 764
Python 3.3+ will happily interpret it as a package without an __init__.py
, fwiw, and I believe that's what the author wrote in.
Also note from trying to run it just now, you'll need to install simplejson
and requests
. (Normally there'd be a requirements.txt
or similar saying this.)
Upvotes: 1