1
adam@adam:~/Untitled Folder/package/web$ cat myscript.py 
from package.settings import sth
adam@adam:~/Untitled Folder/package/web$ python myscript.py 
Traceback (most recent call last):
  File "myscript.py", line 1, in <module>
    from package.settings import sth
ImportError: No module named package.settings
adam@adam:~/Untitled Folder/package/web$ python3 myscript.py 
Traceback (most recent call last):
  File "myscript.py", line 1, in <module>
    from package.settings import sth
ImportError: No module named 'package'

adam@adam:~/Untitled Folder/package$ ls
__init__.py  settings  web 
adam@adam:~/Untitled Folder/package$ cd web 
adam@adam:~/Untitled Folder/package/web$ ls 
myscript.py  __init__.py

How do I run that, then? I tried to run it from every folder (up to the Untitled Folder) with no success. In pycharm it works.

Adam
  • 1,724
  • 4
  • 21
  • 31

1 Answers1

0

Not sure if this is the case but you may have forgotten to install the module. This can be done by:

1.) Installing python-pip if you haven't done so yet:

apt-get install python-pip

2.) Run pip to install your packages (Not sure how pip refers to it as):

pip install <package>

Another thing to check out is applying your project in your Python Path. ImportError: No module named package

Community
  • 1
  • 1
ryekayo
  • 2,341
  • 3
  • 23
  • 51
  • it's my script `cat flaskapp.py from package.settings import sth`, I should rename it in the question to reduce the confusion – Adam May 03 '17 at 18:38
  • Ahh ok i understand.. I just modified my answer. I would check and confirm if you have the packages the compiler is complaining about. – ryekayo May 03 '17 at 18:39
  • The example shall be without any third party packages – Adam May 03 '17 at 18:44