Reputation: 1579
I am new to python and i have this django project, which actually has to communicate with a python package that my colleague has built. Let's say, the structure is as follows
-Mydjangoproject
-myapp
-views.py
-models.py
-Mydjangoproject
-settings.py
-urls.py
-manage.py
-db.sqlite3
-colleagues_python_package
-package1
-script1.py
-script2.py
-package2
-info1.py
-info2.py
When I try to run my colleague's script1.py which has the following code to import,
from colleagues_python_package.package2 import info1
it throws me the error
ImportError: No Module named colleagues_python_package.package2
If run in my colleague's system, this works. Is it because this package is not set in PYTHONPATH. How do I resolve this and explanation? ( and this package has to be inside django project)
Upvotes: 0
Views: 100
Reputation: 1579
Okay I found that I have to import using [dot]'s. For example, if I want to run the script1, I'll have to import info1 as below
from ..package2 import info1
Representation is like,
1 dots - current folder
2 dots - current folder's parent
3 dots - current folder's parent's parent
Hope I ain't confusing.
Upvotes: 2
Reputation: 99
Try importing the module from python manage.py shell
and see if you will get any errors.
Upvotes: 1