Defense notes when pip3 doesn't work with "ImportError: No module named'packaging'" after installing python3-pip on Debian8

Introduction

This is just a defensive record of the python3-pip landmines that I stepped on on February 7, 2017. ~~ Currently unsolved. I will update the article as soon as I know the solution ~~ It seems that it has been solved.

I've only been in python for a few days and am almost an amateur when it comes to python. Please comment if you make a mistake.

Originally, I tried to install Jupyter on the following system.

As a side note, at this point, the python2.7 series was working with pip as follows.

-"Control modules created with Synthesijer with MessagePack-RPC (remote server edition)" @Qiita

I installed python3 but ...

Let's install python3 for the time being.

shell$ sudo apt-get install python3
shell$ sudo apt-get install python3-dev
shell$ sudo apt-get install python3-pip

However, for some reason, when I try to run pip3, it fails.

shell$ sudo pip3 install jupyter
Traceback (most recent call last):
  File "/usr/bin/pip3", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named 'packaging'

I tried upgrading the package

A painful mistake here. I upgrade the package because I think the version / revision of the package is old.

shell# apt-get update
shell# apt-get upgrade

I regretted that I failed in the following two points

  1. I deleted the log when python3 was installed in the previous section.
  2. I have also upgraded python2, which used to work fine.

as a result,

shell$ sudo pip3 install jupyter
Traceback (most recent call last):
  File "/usr/bin/pip3", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named 'packaging'

Not just pip3

shell$ pip --version
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named 'packaging'

It stopped working up to pip.

Find a solution online

At this point, I finally decided to search for a solution online. .. .. As a result, the next page gets stuck.

It seems to be quite recent (about 4 days ago from February 7, 2017).

So, let's try it according to the article here.

shell# apt-get purge -y python-pip
shell# wget https://bootstrap.pypa.io/get-pip.py
shell# python ./get-pip.py
shell# apt-get install python-pip

As a result, pip is back.

shell# pip --version
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)

However, pip3 is still useless.

shell# pip3 --version
Traceback (most recent call last):
  File "/usr/bin/pip3", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named 'packaging'

What should I do? .. .. ~~ (continued) ~~

Get advice on twitter and pip3 works

https://twitter.com/muo_jp/status/828837850464481280

So I tried it.

shell# apt-get purge python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libblas-common libblas3 libgfortran3 liblapack3 python3-chardet
  python3-colorama python3-distlib python3-html5lib python3-pkg-resources
  python3-requests python3-setuptools python3-six python3-urllib3
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  python3-pip*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 452 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 39218 files and directories currently installed.)
Removing python3-pip (1.5.6-5) ...
Processing triggers for man-db (2.7.0.2-5) ...
shell# python3 get-pip.py
Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Requirement already up-to-date: setuptools in /usr/local/lib/python3.4/dist-packages
Collecting wheel
  Using cached wheel-0.29.0-py2.py3-none-any.whl
Collecting six>=1.6.0 (from setuptools)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting appdirs>=1.4.0 (from setuptools)
  Using cached appdirs-1.4.0-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools)
  Using cached packaging-16.8-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools)
  Using cached pyparsing-2.1.10-py2.py3-none-any.whl
Installing collected packages: pip, wheel, six, appdirs, pyparsing, packaging
  Found existing installation: six 1.8.0
    Uninstalling six-1.8.0:
      Successfully uninstalled six-1.8.0
Successfully installed appdirs-1.4.0 packaging-16.8 pip-9.0.1 pyparsing-2.1.10 six-1.10.0 wheel-0.29.0
shell# apt-get install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libblas-common libblas3 libgfortran3 liblapack3
Use 'apt-get autoremove' to remove them.
Recommended packages:
  python3-wheel
The following NEW packages will be installed:
  python3-pip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/97.2 kB of archives.
After this operation, 452 kB of additional disk space will be used.
Selecting previously unselected package python3-pip.
(Reading database ... 39166 files and directories currently installed.)
Preparing to unpack .../python3-pip_1.5.6-5_all.deb ...
Unpacking python3-pip (1.5.6-5) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up python3-pip (1.5.6-5) ...
shell# pip3 --version
pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)

moved!

Recommended Posts

Defense notes when pip3 doesn't work with "ImportError: No module named'packaging'" after installing python3-pip on Debian8
What to do if scrapy doesn't work after installing scrapy with pip on mac
Error when installing a module with Python pip
After installing pygame with conda install No module named font
Error when installing opencv-python on jetson nano (ModuleNotFoundError: No module named'skbuild')
module install if pip install doesn't work
When matplotlib doesn't work with python2.7
Pip doesn't work with PyDev in Pleiades
A workaround when installing pyAudio with pip.
No module named'_ctypes' occurs when installing pipenv