'ImportError: No module named mako
I have installed of python in 2 different location. I have opened two terminals setting environment variable such a way that each terminal finds a different python installation:
TERM1$which python
/A/python
TERM2$which python
/B/python
Later, I installed Mako using one of the installations (I don't remember which one). I installed mako locally using:
python setup.py install --user
My understanding was that, the module will go to the PATH given by:
$python -c 'import site; print site.USER_SITE'
/home/.../.local/lib/python2.7/site-packages
which points to the same location in my /home if I run the above command from either of the terminals.
The problem is that if I run :
python -c 'import mako'
one of the terminals is OK but the other one gives error:
ImportError: No module named mako
Most probably, the search path is different from one terminal(env) to another. But I don't know what to check!
Solution 1:[1]
Try this...in your terminal
$ sudo updatedb
$ locate mako
Both are different commands.
Locate will give you the exact location of where Mako is installed and under which python version.
Chances are it must be installed only for one of the python versions.
You will have to install it for another one to make it work. You can also try changing alias of python to another one in .bashrc and then install Mako in the changed Python version and then try importing the module.
How to switch to a different python version:- http://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux
Solution 2:[2]
pip install mako use this line
Solution 3:[3]
What helped me with this error is this:
$ sudo apt-get install python-pip libyaml-dev
$ sudo pip install prettytable Mako pyaml dateutils --upgrade
Solution 4:[4]
In my case, the Bash version is different from my Apache version:
# Bash
$ python3 -c 'import site; print(site.USER_SITE)'
/Users/me/Library/Python/3.8/lib/python/site-packages
# Apache
/Library/WebServer/Library/Python/3.8/lib/python/site-packages
In terminal - mako is imported fine, but via Apache - it cannot find it ( even if i append to sys.path the direct path )
the answer above hit me, that Apache's user is different than the Bash user ... therefore in my case - i had to install the mako module - globally.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | clickbait |
| Solution 3 | incarnadine |
| Solution 4 | Ricky Levi |
