Python 2.7 cannot install modules after El Capitan upgrade - python

After upgrading my MacOS to El Capita 10.11.6, I cannot run my code because of missing imports.
This one works
$ python -m pip install --user six
But this one fails to install the module.
$ sudo pip install six
Traceback (most recent call last):
File "/usr/local/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
File "/Users/mpme/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 48, in <module>
import six
ImportError: No module named six
Could someone let me know the differences ? Why one works and the other does not?
$ python --version
Python 2.7.13

Related

Can't install pip3 for python 3.9

I've tried everything, I've tried doing the following:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.9 get-pip.py
But that just gives me the following error:
root#ubuntu18:~# python3.9 get-pip.py
Traceback (most recent call last):
File "/root/get-pip.py", line 24184, in <module>
main()
File "/root/get-pip.py", line 139, in main
bootstrap(tmpdir=tmpdir)
File "/root/get-pip.py", line 120, in bootstrap
args = determine_pip_install_arguments()
File "/root/get-pip.py", line 65, in determine_pip_install_arguments
import setuptools # noqa
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 14, in <module>
from setuptools.dist import Distribution, Feature
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 24, in <module>
from setuptools.depends import Require
File "/usr/lib/python3/dist-packages/setuptools/depends.py", line 7, in <module>
from .py33compat import Bytecode
File "/usr/lib/python3/dist-packages/setuptools/py33compat.py", line 54, in <module>
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
And i've sat hours trying different fixes, when i do pip3 --version it shows that its using python 3.6
And your thinking, why do i need to install it for python 3.9, well the py app im using only supports that and when i try to run it using python3.9 app.py it says that there is missing pip3 modules even though its installed.
I hope someone can tell me a fix, or what's causing the error.
Thanks.
This same thing happened to me, my installation wouldn’t compile correctly because a file in python wasn’t updating from a older version. Just reinstall python 3.9 and retry installing pip3 then it should work. It sucks to do but solves more issues down the road.
Try this command to upgrade setuptools
pip3 install --upgrade setuptools
If that doesnt work , try these
pip3 install --upgrade pip
pip3 install --upgrade distlib

ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)

I installed pip3 using sudo apt-get install python3-pip after that when I run the following command to install django sudo pip3 install django I get this error:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in
from pip import main
File "/usr/lib/python3/dist-packages/pip/init.py", line 14, in
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python3/dist-packages/pip/utils/init.py", line 23, in
from pip.locations import (
File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in
from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/init.py)
How do I fix this?
I have tried recently manually installing python3.9 version in my Ubuntu from 3.6 version using apt install python3.9. Then pip3 was broken. The issue is because distutils were not build for the 3.9 version.
So in my case I ran apt install python3.9-distutils to resolve my issue.
In your case make sure to modify 3.x version in distutils command.
This helped but then I got another error: ImportError: No module named 'pip._internal'
The following fixed it:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall

how can i fix this problem with pip on osx?

I am trying all day to reinstall pip or pip3
I always have the same problem when i try to run it:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
ImportError: cannot import name 'load_entry_point'
I tried to uninstall and reinstall pip with curl and then with easy_install and now it's a big mess.
I am on the last Mac-osx release
I guess i should remove pip and pip3 completely, but how?

Mac reinstall Python

I tried to use the Coursera course downloader from here and it worked for few courses but not all. They have recommended to use Python3.X. So I uninstalled Anaconda (version 2) from my Mac and installed Python3.5.1 from Python's website but still the course downloaders did not work as it was using default Python 2.7.
So I deleted Python from /usr/local/lib and now nothing is working. When I do which python it shows ``usr/local/bin/pythonand bothpythonandpython3` runs.
But when I do pip install coursera it throws error as follows:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
And when I do sudo easy_install pip, I get the following error.
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
try Homebrew http://brew.sh/
brew install python3
curl bootstrap.pypa.io/get-pip.py | python3
Your Mac should have Python 2 and Python 3 installed by default. in the terminal "python" will launch Python2, "python3" will launch Python3. With Anaconda you could have just kept the Python 2 version and created an environment for Python 3, http://conda.pydata.org/docs/using/envs.html#managing-environments.
This is the solution you will most likely need, No module named pkg_resources. Setuptools is causing the issue and you will need to wget ez_setup.py. Reinstalling Anaconda will save you a lot of time and pain.

How to install PyWavelets for Python 3 on Kubuntu 14.04?

I'm tryting to install PyWavelets on Kubuntu 14.04, but its not working...
Since we dont have python3-pywt (we have python-pwt, for python 2) on Ubuntu oficial repositories, I tried to install it with pip, so I did:
$ sudo pip3 install pywavelets
And I've got the error:
Downloading/unpacking pywavelets
Downloading PyWavelets-0.2.2.zip (528kB): 528kB downloaded
Running setup.py (path:/tmp/pip_build_root/pywavelets/setup.py) egg_info for package pywavelets
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/pywavelets/setup.py", line 14, in
from util import commands
File "/tmp/pip_build_root/pywavelets/util/commands.py", line 25, in
import templating
ImportError: No module named 'templating'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/pywavelets/setup.py", line 14, in
from util import commands
File "/tmp/pip_build_root/pywavelets/util/commands.py", line 25, in
import templating
ImportError: No module named 'templating'
Any idea?
On Kubuntu 14.04 using Python 3.4, I installed the packages (for Python 3): python3-all-dev, and the respective ones related to numpy and Cython.
Then I clonned the sorce from the github repo pywt repo.
After that I was able to do:
$ python setup.py install --user
The build and install worked perfectly, so I tested if everythink was ok:
$ python3
>>> import pywt
>>> pywt.test()
. . .
OK (SKIP=1)
<nose.result.TextTestResult run=934 errors=0 failures=0>

Categories