Installing Python 3.7.3 on MX-linux 18.1
I was following this blog to install python 3.7.3 on my MX-linux 18.1 machine. Step by step procedure is as follows
-
Install the pre-requisites
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev
-
Download python from the official website like this
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
Extract the downloaded package
sudo tar xzf Python-3.7.3.tgz
-
Compile Python from source
cd Python-3.7.3
sudo ./configure --enable-optimizations
sudo make altinstall
Those people who do not install the libffi-dev
package will face this error ModuleNotFoundError: No module named '_ctypes'
. Hence i have already included the libffi-dev
package in the first step
-
Installing any package through pip3 or pip3.7 you will encounter this error while using it, correct the error.
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.7/site-packages/numpy'
Consider using the `--user` option or check the permissions.
At this point the best option is to use virtualenv or virtualenvwrapper but if you want to get rid of this error then use the --user
option.
pip3.7 install --user pandas
the pandas will be installed but you will not be able to use it. You might see a warning at the end like this(Anyways at this point you should be using virtual environments anyways)
The scripts f2py, f2py3 and f2py3.7 are installed in '/home/someuser/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
If you want to use python and all the modules that you install with pip without any virtual enviroments you will not be able to use it because ~/.local/bin
directory is not added in your PATH
environement variable. So just add this to the end of your .bashrc
file
PATH=$PATH:~/.local/bin/
then do a
source .bashrc
-
Change python symlink to point to python 3.7.3 rather that 2.7
Since use of python 2.7
is going to be obsolete in the near future we change the default python symlink to point directly to python 3.7
. Please navigate to /usr/bin
. You should notice the python symlink
ls -lha /usr/bin/python
lrwxrwxrwx 1 root root 9 Jan 24 2017 /usr/bin/python -> python2.7
Use this command to change it to python 3.7
sudo ln -sfn /usr/local/bin/python3.7 python
Now typing python should open a python 3.7.3 interpreter instead of python 2.7 interpreter
$ python
Python 3.7.3 (default, Apr 18 2019, 11:12:01)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
-
virtualenvwrapper
Install
pip3 install --user virtualenvwrapper
Make a folder called Envs
to store all the virtual environments mkdir Envs
To make virtualenvwrapper work seamlessly everytime you open a new terminal include these lines at the end of .bashrc
export WORKON_HOME=~/Envs
source ~/.local/bin/virtualenvwrapper.sh
and then do a $ source .bashrc
on the terminal
$ mkvirtualenv test
Using base prefix '/usr/local'
New python executable in /home/somename/Envs/test/bin/python3.7
Also creating executable in /home/somename/Envs/test/bin/python
Installing setuptools, pip, wheel...
done.
virtualenvwrapper.user_scripts creating /home/somename/Envs/test/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/somename/Envs/test/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/somename/Envs/test/bin/preactivate
virtualenvwrapper.user_scripts creating /home/somename/Envs/test/bin/postactivate
virtualenvwrapper.user_scripts creating /home/somename/Envs/test/bin/get_env_details
(test) somename@somename:~/.local/bin
$ python
Python 3.7.3 (default, Apr 18 2019, 11:12:01)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
Please leave a comment below if you face any issues. Dont forget to give a star to the gist if you like it.
Excellent work. Thanks :)