1

I have Python 2 available at

# which python
/bin/python

# python --version
Python 2.7.5

And I am installing python 3.7 using following article https://wiki.centos-webpanel.com/install-django

After installing python

# cd /usr/local/src
# wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
# tar xvf Python-3.7.3.tgz
# cd Python-3.7.3
# ./configure --with-ensurepip=install --enable-shared
# make
# make install
# ln -s /usr/local/lib/libpython3.7m.so.1.0 /usr/lib64/libpython3.7m.so.1.0

When i upgrading pip using following command it gives command not found

# pip3.7 install --upgrade pip
bash: pip3.7: command not found

I tried

# python3.7 pip install --upgrade pip
bash: python3.7: command not found

Note: Please note that after installation, the new python binary path will be located at /usr/local/bin/python

Edit1: I have created symslink using following command

[root@host Python-3.7.3]# ln -s /usr/local/lib/libpython3.7m.so.1.0 /usr/lib64/libpython3.7m.so.1.0
[root@host Python-3.7.3]# cd /usr/local/lib/
[root@host lib]# ll
total 13380
lrwxrwxrwx.  1 root root       20 Jul  7 11:09 libpython3.7m.so -> libpython3.7m.so.1.0
-r-xr-xr-x.  1 root root 13678000 Jul  7 11:09 libpython3.7m.so.1.0
-r-xr-xr-x.  1 root root     7680 Jul  7 11:09 libpython3.so
drwxr-xr-x. 15 root root      288 Jun 23 07:11 php
drwxr-xr-x.  2 root root       67 Jul  7 11:09 pkgconfig
drwxr-xr-x. 35 root root     8192 Jul  7 11:09 python3.7

Edit2: I am getting following error after running command from python3.7 folder

[root@host python3.7]# python3.7 -m pip install --upgrade pip
bash: python3.7: command not found
[root@host python3.7]# pwd
/usr/local/lib/python3.7

Edit3:

[root@host python3.7]# python -m pip install -upgrade pip
Could not import runpy module
[root@host python3.7]# python3 -m pip install -upgrade pip
bash: python3: command not found

EDIT4:

[root@host python3.7]# which python3
/usr/bin/which: no python3 in (/sbin:/bin:/usr/sbin:/usr/bin)

EDIT5:

[root@host usr]# cd /usr/local/bin
[root@host bin]# ll
total 23580
lrwxrwxrwx. 1 root root        8 Jul  7 11:09 2to3 -> 2to3-3.7
-rwxr-xr-x. 1 root root      101 Jul  7 11:09 2to3-3.7
-rwxr-xr-x. 1 root root      241 Jul  2 19:24 easy_install-3.7
lrwxrwxrwx. 1 root root        7 Jul  7 11:09 idle3 -> idle3.7
-rwxr-xr-x. 1 root root       99 Jul  7 11:09 idle3.7
-rwxr-xr-x. 1 root root      817 Jul 20  2018 pear
-rwxr-xr-x. 1 root root      838 Jul 20  2018 peardev
-rwxr-xr-x. 1 root root      754 Jul 20  2018 pecl
lrwxrwxrwx. 1 root root        9 Jun 23 07:11 phar -> phar.phar
-rwxr-xr-x. 1 root root    14829 Jul 20  2018 phar.phar
-rwxr-xr-x. 1 root root 12036016 Jul 20  2018 php
-rwxr-xr-x. 1 root root 12009264 Jul 20  2018 php-cgi
-rwxr-xr-x. 1 root root     3232 Jul 20  2018 php-config
-rwxr-xr-x. 1 root root     4526 Jul 20  2018 phpize
-rwxr-xr-x. 1 root root      223 Jul  2 19:24 pip3
-rwxr-xr-x. 1 root root      223 Jul  2 19:24 pip3.7
lrwxrwxrwx. 1 root root        8 Jul  7 11:09 pydoc3 -> pydoc3.7
-rwxr-xr-x. 1 root root       84 Jul  7 11:09 pydoc3.7
lrwxrwxrwx. 1 root root        9 Jul  7 11:09 python3 -> python3.7
-rwxr-xr-x. 2 root root    11200 Jul  7 11:09 python3.7
lrwxrwxrwx. 1 root root       17 Jul  7 11:09 python3.7-config -> python3.7m-config
-rwxr-xr-x. 2 root root    11200 Jul  7 11:09 python3.7m
-rwxr-xr-x. 1 root root     3097 Jul  7 11:09 python3.7m-config
lrwxrwxrwx. 1 root root       16 Jul  7 11:09 python3-config -> python3.7-config
lrwxrwxrwx. 1 root root       10 Jul  7 11:09 pyvenv -> pyvenv-3.7
-rwxr-xr-x. 1 root root      441 Jul  7 11:09 pyvenv-3.7

EDIT6:

# python -m pip install --upgrade pip
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages (20.1.1)
9
  • Where did you place the binaries? Somewhere your $PATH is pointing to? – Panki Jul 7 '20 at 12:53
  • When you compiled from source, did you get any warnings or errors about pip being ignored or not installed? What is the output of /usr/local/bin/python --version and /usr/local/bin/python -m pip --version? – GracefulRestart Jul 7 '20 at 19:49
  • @Panki, I have changed my $PATH by using following command export PATH="/usr/local/src:$PATH" – Maqsud Inamdar Jul 7 '20 at 23:52
  • @GracefulRestart I have added my warnings in question. Please check my EDIT6: – Maqsud Inamdar Jul 7 '20 at 23:55
  • You need to prepend the location of where the python and pip binaries for 3.7 are located. – Nasir Riley Jul 8 '20 at 0:03
1

The directory that the Python 3.7 executable is installed in, /usr/local/bin, is not located in your PATH. You can see your PATH in the error returned from running which python3, which printed /sbin:/bin:/usr/sbin:/usr/bin as the PATH. You can also view what your path is by printing the contents of the variable to the terminal, e.g. echo $PATH.

You can temporarily add /usr/local/bin to your path by running the command:

export PATH="$PATH:/usr/local/bin"

This will set the $PATH variable to the current contents of itself, but with /usr/local/bin appended. Entries in the shells PATH are separated by colons (:).

To permanently set your PATH to include /usr/local/bin you will have to modify your shell's login profile file, to give the most common shell as an example bash will have a file named .bash_profile in your home directory, or .profile if .bash_profile is not present. At the bottom of that file you can add the aforementioned command to export the path every time you log in, ensuring that you will be able to access Python 3.7 with minimal hassle immediately after logging in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.