Sometimes you can run in circle on Linux, just be careful

Today I found the interesting presentation about why Linux still sucks even on 2020:

Linux Sucks 2020: https://www.youtube.com/watch?v=cZN5n6C9gM4

Each year the author of this presentation updates it and present again.

Although I’m Linux only since 1999, I think he is right and many points.

And today a funny thing happen to me: I decided to test NuttX on ESP32 and because I already did it in the past I decied to follow my own post: https://acassis.wordpress.com/2018/01/04/running-nuttx-on-esp32-board/

$ sudo pip install esptool
sudo: pip: command not found

Strange, I though Ubuntu should come with it…

$ pip
Command 'pip' not found, but there are 18 similar ones.

No, it is not where!

Let’s to install it using pip:

$ sudo apt install pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package pip

After some seconds searching on google…

Found a stackoverflow!!!

https://stackoverflow.com/questions/9780717/bash-pip-command-not-found

“Why not just do sudo easy_install pip or if this is for python 2.6 sudo easy_install-2.6 pip?”

It has 508 hits, it can’t be wrong!

$ sudo easy_install pip
sudo: easy_install: command not found

Arrggg, “easy_install” is not installed

Let’s to install it:

$ sudo apt install easy_install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package easy_install

Probably the package has other name!

Wait, I have the fantastic “apt-file”, let’s ask it which package has the easy_install

$ apt-file search easy_install
ansible: /usr/lib/python3/dist-packages/ansible/modules/packaging/language/easy_install.py
ansible-doc: /usr/share/doc/ansible/html/modules/easy_install_module.html
pypy-setuptools: /usr/lib/pypy/dist-packages/easy_install.py
pypy-setuptools: /usr/lib/pypy/dist-packages/setuptools/command/easy_install.py
python-setuptools: /usr/lib/python2.7/dist-packages/easy_install.py
python-setuptools: /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py
python-setuptools: /usr/share/doc/python-setuptools/easy_install.txt.gz
python-setuptools-doc: /usr/share/doc/python-setuptools-doc/html/_sources/easy_install.txt
python-setuptools-doc: /usr/share/doc/python-setuptools-doc/html/easy_install.html
python3-setuptools: /usr/lib/python3/dist-packages/easy_install.py
python3-setuptools: /usr/lib/python3/dist-packages/setuptools/command/easy_install.py
python3-setuptools: /usr/share/doc/python3-setuptools/easy_install.txt.gz
python3-zc.buildout: /usr/lib/python3/dist-packages/zc/buildout/easy_install.py
python3-zc.buildout: /usr/lib/python3/dist-packages/zc/buildout/easy_install.txt
python3-zc.buildout: /usr/share/doc/python3-zc.buildout/reference/easy_install.txt.gz

Because I’m using python3, it should be python3-setuptools

$ sudo apt install python3-setuptools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libjaylink0 libjim0.79
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  python-setuptools-doc
The following NEW packages will be installed:
  python3-setuptools
0 upgraded, 1 newly installed, 0 to remove and 129 not upgraded.
Need to get 330 kB of archives.
After this operation, 1.466 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-setuptools all 45.2.0-1 [330 kB]
Fetched 330 kB in 1s (255 kB/s)             
Selecting previously unselected package python3-setuptools.
(Reading database ... 268191 files and directories currently installed.)
Preparing to unpack .../python3-setuptools_45.2.0-1_all.deb ...
Unpacking python3-setuptools (45.2.0-1) ...
Setting up python3-setuptools (45.2.0-1) ...

Now it should work!

$ sudo easy_install pip
sudo: easy_install: command not found

Oh!!! Come on!!!

Let’s see what is inside python3-setuptools:

$ dpkg -L python3-setuptools
...
/usr/lib/python3/dist-packages/easy_install.py
/usr/share/doc/python3-setuptools/easy_install.txt.gz
/usr/share/doc/python3-setuptools/formats.txt.gz
/usr/share/doc/python3-setuptools/history.txt
/usr/share/doc/python3-setuptools/index.txt
/usr/share/doc/python3-setuptools/python3.txt
/usr/share/doc/python3-setuptools/releases.txt
/usr/share/doc/python3-setuptools/roadmap.txt
/usr/share/doc/python3-setuptools/setuptools.txt.gz
/usr/share/doc/python3-setuptools/changelog.Debian.gz

Hmm, there is a easy_install.txt.gz file inside the python3-setuptools, it should be useful:

$ vi /usr/share/doc/python3-setuptools/easy_install.txt.gz



.. warning::
    Easy Install is deprecated. Do not use it. Instead use pip. If
    you think you need Easy Install, please reach out to the PyPA
    team (a ticket to pip or setuptools is fine), describing your
    use-case.

Damn it! I’m trying to use “pip” from start!

I should just have search for it using apt-file and filter for bin directories:

$ apt-file search pip | grep bin
….
python3-pip: /usr/bin/pip3
python3-pipdeptree: /usr/bin/pipdeptree
rt-tests: /usr/bin/pip_stress
rubber: /usr/bin/rubber-pipe

Ok, the package python3-pip appears promising…

Let’s to install it:

$ sudo apt 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:
  libjaylink0 libjim0.79
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  python-pip-whl python3-wheel
The following NEW packages will be installed:
  python-pip-whl python3-pip python3-wheel
0 upgraded, 3 newly installed, 0 to remove and 129 not upgraded.
Need to get 2.053 kB of archives.
After this operation, 3.455 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://br.archive.ubuntu.com/ubuntu focal/universe amd64 python-pip-whl all 20.0.2-5ubuntu1 [1.799 kB]
Get:2 http://br.archive.ubuntu.com/ubuntu focal/universe amd64 python3-wheel all 0.34.2-1 [23,8 kB]
Get:3 http://br.archive.ubuntu.com/ubuntu focal/universe amd64 python3-pip all 20.0.2-5ubuntu1 [230 kB]
Fetched 2.053 kB in 1s (1.736 kB/s)  
Selecting previously unselected package python-pip-whl.
(Reading database ... 268295 files and directories currently installed.)
Preparing to unpack .../python-pip-whl_20.0.2-5ubuntu1_all.deb ...
Unpacking python-pip-whl (20.0.2-5ubuntu1) ...
Selecting previously unselected package python3-wheel.
Preparing to unpack .../python3-wheel_0.34.2-1_all.deb ...
Unpacking python3-wheel (0.34.2-1) ...
Selecting previously unselected package python3-pip.
Preparing to unpack .../python3-pip_20.0.2-5ubuntu1_all.deb ...
Unpacking python3-pip (20.0.2-5ubuntu1) ...
Setting up python3-wheel (0.34.2-1) ...
Setting up python-pip-whl (20.0.2-5ubuntu1) ...
Setting up python3-pip (20.0.2-5ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...

And finally I need to use pip3 instead pip:

$ sudo pip3 install esptool
Collecting esptool
  Downloading esptool-2.8.tar.gz (84 kB)
     |████████████████████████████████| 84 kB 961 kB/s 
Collecting ecdsa
  Downloading ecdsa-0.15-py2.py3-none-any.whl (100 kB)
     |████████████████████████████████| 100 kB 2.2 MB/s 
Collecting pyaes
  Downloading pyaes-1.6.1.tar.gz (28 kB)
Collecting pyserial>=3.0
  Downloading pyserial-3.4-py2.py3-none-any.whl (193 kB)
     |████████████████████████████████| 193 kB 3.3 MB/s 
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from ecdsa->esptool) (1.14.0)
Building wheels for collected packages: esptool, pyaes
  Building wheel for esptool (setup.py) ... done
  Created wheel for esptool: filename=esptool-2.8-py3-none-any.whl size=142114 sha256=c5b3fd7c8d295624dea3a3f30141063ad870efa929e85069a47c7cf311421733
  Stored in directory: /root/.cache/pip/wheels/4a/4c/c7/aa45baeba596ab0e9d624a32e3f5680db5aed6773ae1ffa5ed
  Building wheel for pyaes (setup.py) ... done
  Created wheel for pyaes: filename=pyaes-1.6.1-py3-none-any.whl size=26345 sha256=9d9a353e43d3ae217edf90d80eedf14393aab7a2288949d1b2118598c55a823b
  Stored in directory: /root/.cache/pip/wheels/aa/ca/9c/8a3c00512585c703edc457db81c066b9609d76758c74f72ac6
Successfully built esptool pyaes
Installing collected packages: ecdsa, pyaes, pyserial, esptool
Successfully installed ecdsa-0.15 esptool-2.8 pyaes-1.6.1 pyserial-3.4

As you can see I spend some time just because I forgot to use the right command. I should have started search for “pip” using the apt-file command.

But also the package names on Linux should be more intuitive and follow the name of the specific command.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s