ImportError: No module named sysconfig--cant get pip working

2024/10/11 4:27:44

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_pointFile "/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 Environmentself, search_path=None, platform=get_supported_platform(),File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 180, in get_supported_platformplat = get_build_platform()File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 380, in get_build_platformfrom sysconfig import get_platformImportError: 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
Answer

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_pointFile "/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 Environmentself, search_path=None, platform=get_supported_platform(),File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 180, in get_supported_platformplat = get_build_platform()File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 380, in get_build_platformfrom 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)
https://en.xdnf.cn/q/69813.html

Related Q&A

Convert Dataframe to a Dictionary with List Values

Suppose I have a Dataframe df :Label1 Label2 Label3 key1 col1value1 col2value1 key2 col1value2 col2value2 key3 col1value3 col2value3dict1 = df.set_index(Label1).to_dic…

Efficiently count all the combinations of numbers having a sum close to 0

I have following pandas dataframe df column1 column2 list_numbers sublist_column x y [10,-6,1,-4] a b [1,3,7,-2] p q [6,2,-3,-3.…

What is the equivalent to iloc for dask dataframe?

I have a situation where I need to index a dask dataframe by location. I see that there is not an .iloc method available. Is there an alternative? Or am I required to use label-based indexing?For …

How to deal with limitations of inspect.getsource - or how to get ONLY the source of a function?

I have been playing with the inspect module from Pythons standard library. The following examples work just fine (assuming that inspect has been imported):def foo(x, y):return x - y print(inspect.getso…

Checking whether a function is decorated

I am trying to build a control structure in a class method that takes a function as input and has different behaviors if a function is decorated or not. Any ideas on how you would go about building a f…

How to keep the script run after plt.show() [duplicate]

This question already has answers here:Is there a way to detach matplotlib plots so that the computation can continue?(21 answers)Closed 6 years ago.After the plt.show() , I just want to continue. How…

python - Simulating else in dictionary switch statements

Im working on a project which used a load of If, Elif, Elif, ...Else structures, which I later changed for switch-like statements, as shown here and here.How would I go about adding a general "Hey…

Allow dynamic choice in Django ChoiceField

Im using Select2 in my application for creating tags-like select dropdowns. Users can select number of predefined tags or create a new tag.Relevant forms class part:all_tags = Tag.objects.values_list(i…

Row-wise unions in pandas groupby

I have a large data frame that looks like so (and is copy-pasteable with df=pd.read_clipboard(sep=\s\s+):user_nm month unique_ips shifted_ips halves quarters mo_pairs100118231 2 set(…

Add seaborn.palplot axes to existing figure for visualisation of different color palettes

Adding seaborn figures to subplots is usually done by passing ax when creating the figure. For instance:sns.kdeplot(x, y, cmap=cmap, shade=True, cut=5, ax=ax)This method, however, doesnt apply to seabo…