install python 3.5.2 into ubuntu 16.04 [duplicate] - python

This question already has answers here:
How to download and use python on ubuntu? [closed]
(4 answers)
Closed 2 years ago.
I want to change the python version from 3.6 to 3.5.
I installed python3.5 on ubuntu 16.04. but it is not in usr/bin
I executed update-alternatives --display python3
python3 - auto mode
link best version is /usr/bin/python3.6
link currently points to /usr/bin/python3.6
link python3 is /usr/bin/python3
/usr/bin/python3.6 - priority 3
/usr/local/lib/python3.5 - priority 1
/usr/local/lib/python3.6 - priority 2
But I execute python3 -V
Python 3.5.2
When I try to install some packages using pip
pip install pymysql
-bash: /home/ubuntu/.local/bin/pip: /usr/bin/python3: bad interpreter: Permission denied
I want to correctly install python 3.5.2 on the computer and set it as the default version.

1) Install pre-requiste
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
2) Move to src folder and get the tar of python3.5.2
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
3) Now extract the downloaded archive on your system.
sudo tar xzf Python-3.5.2.tgz
4) Compile the source using alInstall
cd Python-3.5.2
sudo ./configure --enable-optimizations
sudo make altinstall
5) Check the install
python3.5 -V

Related

RPM installation Trino throws python dependency

I'm trying to install Trino using RPM on Red Hat Enterprise Linux distribution. I install the Trino dependencies using the following commands:
$ sudo yum update -y
$ sudo yum install -y java-11-openjdk.x86_64 python3
$ sudo alternatives --set python /usr/bin/python3
Then I try to install Trino from archive in single-node mode. This however gives a dependency error:
$ sudo rpm -i trino-server-rpm-368.rpm
error: Failed dependencies:
python >= 2.4 is needed by trino-server-rpm-0:368-1.noarch
This error doesn't make sense to me given that this dependency is actually satisfied when checking my python version:
$ python -V
Python 3.6.8
An answers has been provided by #hashhar on this Github Issue if you actually have the correct dependencies installed:
$ sudo rpm -i --nodeps trino-server-rpm-368.rpm

python3.7 No module named pip

i had a problem with installing packages to new upgraded python to version 3.7
When i type:
python3.7 -m pip install pip -d
/usr/local/bin/python3.7: No module named pip
I make easy_install like this: sudo easy_install pip what solve previous problems, but now it create pip3.7 in a weird way. Whem i calling for pip3.8 version, this returns me a message:
pip3.7 -V
pip 19.2.3 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
Someone know what i am doing wrong? I tried many things to resolve it. Reinstall, purge, install with symbolic link from python2 etc.
There is a script which i used to install python3.7 (i had also a problem with zlib):
sudo cd /home
sudo wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
sudo tar xf Python-3.7.3.tar.xz
sudo cd ./Python-3.7.3/
sudo ./configure
sudo make
sudo make install
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3 10
python3 --version
Where is a mistake?
Answer finally i find myself. There: https://linuxize.com/post/how-to-install-python-3-7-on-debian-9/
There with similar errors you can recompile it, even without removal (on secound machine i checked without removal) failed installation before.
If someone want to good upgrade with everywith working on debian 9. I recommend that script:
NOW_DIR=$(pwd)
apt update
apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
mkdir ~/python_upgrade
cd ~/python_upgrade
curl -O https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
tar -xf Python-3.7.3.tar.xz
cd Python-3.7.3
./configure --enable-optimizations
make -j $(nproc)
make altinstall
python3.7 --version
cd $NOW_DIR
rm -rf ~/python_upgrade
There are minor changes from that commands in tutorial. Run above file.sh as root.
It can take some times, on my virtual machine with 2 cores during another job it takes 40 minutes. I hope someone find there good answer, not totally green comments like 'apt install' which is first try action before looking to web.

Install PyQt5 on Raspberry for Python3.6

Since I found no answer for my question, neither in older posts nor in other forums, I want to ask the stackoverflow community for advice.
I am using a raspberry pi 3B+, version 9.4 (lite) with kernel version 4.14.71-v7.
I use python3.6. I installed it as follows:
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
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
sudo tar xzf Python-3.6.0.tgz
sudo -s
cd Python-3.6.0
bash configure
make altinstall
exit
Installation was without any trouble and everything works perfectly.
Now I wanted to install the PyQt5 modul for python3.6. I usually use
sudo python3.6 -m pip install ...
for installing a modul for python3.6. Trying
sudo python3.6 -m pip install pyqt5
gave me the error message
Could not find a version that satisfies the requirement PyQt5 (from versions: )
No matching distribution found for PyQt5
So I tried
sudo apt-get update
sudo apt-get install qt5-default pyqt5-dev pyqt5-dev-tools
But it installed PyQt5 for python3.5 (which is preinstalled) on the raspberry.
So does anybody know how to use or install PyQt5 for the subsequently installed
python3.6?
Edit 08.03.2019:
Thanks FlyingTeller. I started to build from source. I followed the steps from
your link.
sudo apt-get update
cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/sip/sip-4.19.14.tar.gz
sudo tar xzf sip-4.19.14.tar.gz
cd sip-4.19.14
sudo -s
python3.6 configure.py --sip-module=PyQt5.sip
make
make install
cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt5_gpl-5.12.tar.gz
sudo tar xzf PyQt5_gpl-5.12.tar.gz
cd PyQt5_gpl-5.12
python3.6 configure.py
Then I received the following error
Error: Use the --qmake argument to explicitly specify a working Qt qmake.
I think I am on the right way, but I do not understand what qmake is or what it
means.
Edit 10.03.2019:
I could solve the last error message. I installed
sudo apt-get install qt5-default
Then I did the same procedure as already mentioned. Now I get the error
fatal error: sip.h: File or directory not found
#include <sip.h>
PyQt5 config.py is in: /usr/src/PyQt5_gpl-5.12
SIP sip.h is in: /usr/src/sip-4.19.14
Anybody an idea? Thanks guys.
Today I found the solution. The steps below worked for me, without any error. The whole process took almost two hours.
sudo apt-get update
sudo apt-get install qt5-default
sudo apt-get install sip-dev
cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/sip/sip-4.19.14.tar.gz
sudo tar xzf sip-4.19.14.tar.gz
cd sip-4.19.14
sudo python3.6 configure.py --sip-module PyQt5.sip
sudo make
sudo make install
cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt5_gpl-5.12.tar.gz
sudo tar xzf PyQt5_gpl-5.12.tar.gz
cd PyQt5_gpl-5.12
sudo python3.6 configure.py
sudo make
sudo make install
Seems like they moved some things around. This seems to work, as far as getting things, and compiling them. It takes a long time to build.
For the associated designer, look at:
QtDesigner for Raspberry Pi
sudo apt-get update
sudo apt-get install qt5-default
sudo apt-get install sip-dev
cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/sip/4.19.23/sip-4.19.23.tar.gz
sudo tar xzf sip-4.19.23.tar.gz
cd sip-4.19.23
sudo python3 configure.py --sip-module PyQt5.sip
sudo make
sudo make install
cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/PyQt5/5.13.2/PyQt5-5.13.2.tar.gz
sudo tar xzf PyQt5-5.13.2.tar.gz
cd PyQt5-5.13.2
sudo python3 configure.py
sudo make
sudo make install
In my case it helped to update pip from verion 18 to the newest, in my case 20.2 (python -m pip install --upgrade pip) and then do a pip install PyQt5.
The instructions used in the accepted answer did not work for me. I think it's simply because they are outdated. I wanted to post the list of commands that did work for me. I'm running a Pi 400 with the latest version of Raspbian as of 12/20/2020. I used the default python3 rather than python3.6.
Here is the modified list of commands that worked for me:
sudo apt-get install qt5-default
sudo apt-get install sip-dev
cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/sip/sip-5.5.1.dev2011271026.tar.gz
sudo tar xzf sip-5.5.1.dev2011271026.tar.gz
cd sip-5.5.1.dev2011271026
sudo python3 setup.py build
sudo python3 setup.py install
sudo wget https://files.pythonhosted.org/packages/28/6c/640e3f5c734c296a7193079a86842a789edb7988dca39eab44579088a1d1/PyQt5-5.15.2.tar.gz
sudo tar xzf PyQt5-5.15.2.tar.gz
cd PyQt5-5.15.2
sudo python3 configure.py
sudo make
sudo make install
Can't comment due to reputation but I would add to Christ Troutner's useful updated answer, that in case users get a No module named 'PyQt5.sip' error, try --sip-module PyQt5.sip during configure, per the docs:
Note
When building PyQt5 v5.11 or later you must configure SIP to create a
private copy of the sip module using a command line similar to the
following:
python configure.py --sip-module PyQt5.sip
If you already have SIP installed and you just want to build and
install the private copy of the module then add the --no-tools option.
The accepted answers did not work for me, below is the code that worked for me.
sudo apt-get update
sudo apt-get install qt5-default
sudo apt-get install qtcreator
This code not only installs Qtcreator but also installs Qt5 Assistant, Qt5 Designer, and Qt5 Linguist

Upgrade Python version in Linux Mint

I am following this guide:
http://www.experts-exchange.com/articles/18641/Upgrade-Python-2-7-6-to-Python-2-7-10-on-Linux-Mint-OS.html
It says to do
make install
When I do that it says:
If I do: su then enter passowrd and then make install
same error appears.
How can I solve this?
You are probably following wrong steps. Before installing the Python from the source you should install required packages and configure source accordingly. So I suggest you to follow the steps:
Install Required Packages
$ 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
Download and extract Python 2.7.10
$ cd /usr/src
$ wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
$ tar xzf Python-2.7.10.tgz
Compile Python Source
$ cd Python-2.7.10
$ sudo ./configure
$ sudo make altinstall
Check the Python Version
$ python2.7 -V
Source: http://tecadmin.net/install-python-2-7-on-ubuntu-and-linuxmint/

Failed to re-build pycurl with OpenSSL

I'm trying to rebuild pycurl with OpenSSL because of this bug.
I use this example:
sudo apt-get install build-essential fakeroot dpkg-dev
mkdir ~/python-pycurl-openssl
cd ~/python-pycurl-openssl
sudo apt-get source python-pycurl
sudo apt-get build-dep python-pycurl
sudo apt-get install libcurl4-openssl-dev
sudo dpkg-source -x pycurl_7.19.3-0ubuntu3.dsc
cd pycurl-7.19.3
edit debian/control file and replace all instances of 'libcurl4-gnutls-dev' with 'libcurl4-openssl-dev' (7 changes)
sudo PYCURL_SSL_LIBRARY=openssl dpkg-buildpackage -rfakeroot -b
sudo dpkg -i ../python-pycurl_7.19.3-0ubuntu3_amd64.deb
But after all I'm still stuck with GnuTLS build of pycurl.
>>> pycurl.version
'PycURL/7.19.5.1 libcurl/7.35.0 GnuTLS/2.12.23 zlib/1.2.8 libidn/1.28 librtmp/2.3'
Operation log (there are some error's tracebacks): http://pastebin.com/6hUEUGar
I use:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty
What am I doing wrong?
I could solve the problem using pip:
sudo pip uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
sudo pip install pycurl --upgrade
Now:
>>> pycurl.version
'PycURL/7.19.5.1 libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3'
But I'm not sure It's right. Why are there two package in the system?
Or it's ok and python is just linked to one of them?

Categories