I have installed ubuntu on my laptop and i have installed python, after installing python2.7.5 i was trying to run a python script on terminal, but it said module no found, i started to download all the modules but it still said module not found. After upgrading to python2.7.9 it still said same so i installed python iddle shell which is importing the modules correctly.
Why is it happening ? why is it working on the python shell but not on terminal. terminal is only recognizing modules like sys, os.. and some built-in modules but not the installed. I would appreciate the help. (I just started to use linux)
It seems that your Python shell uses a diffenrent PYTHONPATH than the python you execute in the terminal. You can verify that by typing
import sys
print sys.path
in both shells and comparing the two outputs. I assume that the installed module path(s) are missing in the output of the python started in the terminal.
you can solve this by defining a PYTHONPATH in your shell:
export PYTHONPATH=...
... means all paths of the python shell's output separated by :
Don't use spaces. If there spaces in one of the paths, surround ... with quotes
export PYTHONPATH="path with spaces:other path:path
"
Start python from that terminal where you entered the export command. Try to import your modules. If it works, make the export permanent by appending it in your .profile located in your home directory.
ls -a $HOME
shows the file (and many others ;-). It is a .file. .files are hidden on a simple ls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With