I downloaded the source code of python 2.7.14 and built it and installed it on linux ( Red Hat 4.8.5-16 ). I have earlier installed python-magic
and requests
libraries. Now when I try to import modules installed using pip
, I get this:
$ python2 Python 2.7.14 (default, Nov 9 2017, 09:05:45) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import magic Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named magic >>> import requests Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named requests
while similar thing works perfectly fine in python 2.7.5 (default with the RHEL system)
$ python Python 2.7.5 (default, May 3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import magic >>> import requests >>>
Am I missing any configuration step here?
Advertisement
Answer
The modules installed via pip
are only available to the standard python version. You need to install your desired packages for the non-standard python versions as well (see also Installing Python Modules)
python2 -m pip install python-magic python2 -m pip install requests