Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named sysconfig--can't get pip working

I'm really struggling with pip on a RedHat 6.9 system. Every time I tried to use pip, I got

ImportError: No module named sysconfig

I tried Googling for solutions. I don't have apt-get and can't seem to get it with yum, so purging setuptools was out of the question. I did my best to delete setuptools by hand so I could reinstall them, but yum is convinced there are still setuptools on the machine.

Pretty much any of the advice involving downloading something with yum doesn't work for me. Yum always says it can't find what I'm looking for. So if there's a way I can download something without yum or apt-get (for example, not through the terminal), that would probably be best.

I have both Python 3 and Python 2 on my machine, so I don't know if that will change the advice that you guys can give me.

1000 thanks to anyone who can help! Right now I can only get things done through anaconda interfaces (such as Jupyter notebooks and Spyder) which is really limiting.

EDIT: Here is my error trace:

Traceback (most recent call last):

  File "/usr/bin/pip2", line 5, in <module>

    from pkg_resources import load_entry_point

  File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 947, in <module>

    class Environment(object):

  File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 951, in Environment

    self, search_path=None, platform=get_supported_platform(),

  File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 180, in get_supported_platform

    plat = get_build_platform()

  File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 380, in get_build_platform

    from sysconfig import get_platform

ImportError: No module named sysconfig

EDIT 2: @hoefling requested that I post the output of the following commands; first:

$ yum list installed | grep setuptools
*Note* Red Hat Network repositories are not listed below. You must run this command as root to access RHN repositories.
python-setuptools.noarch     0.6.10-4.el6_9      @ncep-base-x86_64-workstation-6

and:

$ grep ^Version: /usr/lib/python2.6/site-packages/setuptools-*.egg-info/PKG-INFO
grep: /usr/lib/python2.6/site-packages/setuptools-*.egg-info/PKG-INFO: No such file or directory
like image 791
ribs2spare Avatar asked Jun 07 '18 13:06

ribs2spare


2 Answers

I've got the same error with python2.6 on redHat server 6.9 :

pip version
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 947, in <module>
    class Environment(object):
  File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 951, in Environment
    self, search_path=None, platform=get_supported_platform(),
  File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 180, in get_supported_platform
    plat = get_build_platform()
  File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 380, in get_build_platform
    from sysconfig import get_platform
ImportError: No module named sysconfig

I removed :

rm /usr/lib/python2.6/site-packages/pkg_resources*

and i reinstalled python-setuptools

yum reinstall python-setuptools

After this fix :

pip --version
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)
like image 150
AlexisLP Avatar answered Nov 11 '22 19:11

AlexisLP


Try with

python3 -m ensurepip --default-pip

then do

pip3 install [package]

this will instruct python to use pip3

like image 36
R__raki__ Avatar answered Nov 11 '22 20:11

R__raki__