pip cannot confirm SSL certificate: SSL module is not available - python

I am trying to install RPi.GPIO for Python 3.6 on my Raspberry Pi Zero W, but somehow it won't connect to the python.org website. I have pip installed for 2.7, 3.0, and 3.6 installed, so when I go and do something like:
sudo pip3.6 install RPi.GPIO
I get this error:
pi#raspberrypi:~ $ sudo pip3.6 install RPi.GPIO
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting RPi.GPIO
Could not fetch URL https://pypi.python.org/simple/rpi-gpio/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement RPi.GPIO (from versions: )
No matching distribution found for RPi.GPIO
I did try sudo apt-get install openssl and so on, but it still doesn't work. I can access the website perfectly on my desktop and phone, but my Raspberry Pi won't at all. Any idea what I can do?

Before installing python 3.6 you need to install the libraries needed.
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
Do you have these installed on the PI?
More details here

I encounter the same problem,finally I solved it by following
Check whether the openssl-devel has been installed.
My OS is centos6 and the installing command is as following
yum install openssl-devel -y
Edit python source configure file
vi /{yourpythonsource}/Modules/Setup
. Uncomment some of content as following
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
recompile python.
cd /{yourpythonsource}
make && make install
Now pip3 should be ok.

Related

Ubuntu 18.04 python3.7 confluent-kafka no module named 'confluent_kafka.cimpl'

I have VM run on ubuntu 18.04.
On that I installed:
python3.7
confluent-kafka
when run python script, I met this message error:
from .cimpl import (Consumer, #noqa
ModuleNotFoundError: no module named 'confluent_kafka.cimpl'
I've tried to run/install/remove in many ways but this error still occurred.
I don't know why. Please help me.
Install modules confluent_kafka
pip3 install confluent_kafka
or try these steps
sudo apt-get install librdkafka1
sudo apt-get install librdkafka-dev
sudo apt-get install libssl-dev
sudo apt-get install liblz4-dev
sudo apt-get install libsasl2-dev
git clone https://github.com/confluentinc/confluent-kafka-python.git
cd confluent-kafka-python; ./configure ; make ; sudo make install

Error SSL with python (https)

I am under debian 8
I'd tried to instal : python-telegram-bot (https://github.com/python-telegram-bot/python-telegram-bot) but when I did "python setup.py install" it make an error :
Installed /usr/local/lib/python2.7/site-packages/python_telegram_bot-5.3.1-py2.7.egg
Processing dependencies for python-telegram-bot==5.3.1 Searching for certifi
Reading https://pypi.python.org/simple/certifi/
Download error on https://pypi.python.org/simple/certifi/: unknown url type: https -- Some packages may not be found!
So I have tried to re-install python 2.7.13 with open-ssl:
apt-get install opensll
apt-get install libssl-dev
I edited the /Modules/setup.dist :
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable: SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
After that, I ran ./configure and make && make install
I have the error :during install :
Makefile:1081: recipe for target 'libinstall' failed make: *** [libinstall]
Error 1
And python-telegram-bot would'n compile ...
Can someone have a idea ?
Thanks you very much.
Regards
I would recommend trying to reinstall python2.7 after installing OpenSSL, as was suggested in the following stackoverflow answer:
https://stackoverflow.com/a/19926770/3826254
Or simply use pip to install the python package instead.
I got exactly the same error when I was trying to install python2.7.13 from source.
I tried a lot of things and after spending a lot of time got to know that one of the library libreadline6-dev was missing.
So installed it:
sudo apt-get install libreadline6-dev
and it worked fine for me.
Here are the commands which I used to compile and make install (inside Python-2.7.13 directory:
./configure --prefix /usr/bin/python2.7.13
sudo make altinstall

Pyodbc installation error on Ubuntu 16.04 with Sql Server installed

I am trying to test my scripts for data migration from mssql-server to oracle server. For this, I have to install pyodbc python package for Ubuntu, it has the dependency of unixodbc. When I try to install unixodbc-dev using:
sudo apt-get install unixodbc-dev
It gives broken packages error:
The following packages have unmet dependencies:
unixodbc-dev : Depends: unixodbc (= 2.3.1-4.1)
Depends: odbcinst1debian2 (= 2.3.1-4.1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
But with aptitude (sudo aptitude install unixodbc-dev) it is installing and also removing some SQL server files due to which my SQL-server goes down.
Again on installing SQL server with this command:
sudo apt-get install mssql-server mssql-tools -y
it removes unixodbc:
Removing unixodbc-dev (2.3.1-4.1) ...
Removing unixodbc (2.3.1-4.1) ...
Removing libodbc1:amd64 (2.3.1-4.1) ...
Removing odbcinst (2.3.1-4.1) ...
Removing odbcinst1debian2:amd64 (2.3.1-4.1) ...
Hence again, I am left only with SQL-server and no unixodbc(pyodbc doesn't works). I understand that there is some dependency issue between both of the packages.
Is there is a way to Install both on the same machine or do I have to use 2 machines here?
Finally, I've got the solution from Microsoft's website only.
Here is the method for setting up unixodbc with mssql on Ubuntu 16.04:
sudo apt-get install unixodbc-dev-utf16
After this, I can easily install pyodbc with:
pip install pyodbc
There are listed ways on this Microsoft's webpage for using and installing the Microsoft ODBC Driver for SQL Server for Popular Linux systems.
Here is the easiest installation method for on Ubuntu 16.04 that I've found:
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools
sudo apt-get install unixodbc-dev-utf16 #this step is optional but recommended*
I do not have Sql server installed but when I want to install pyodbc at new machine, I can't install it as well. Someone suggest the following (I can't exactly tell where I find it):
sudo apt-get install unixodbc-dev
sudo pip install pyodbc

pip error while installing Python: "Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS"

I downloaded the Python 3.5 source code and ran the following:
$ tar -xf Python-3.5.2.tar.xz
$ ./configure --with-ensurepip=upgrade
$ make
$ sudo make altinstall
It proceeded well until make. When sudo make altinstall ran, it printed:
Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS
What went wrong?
You are most likely not compiling Python with SSL/TLS support - this is likely because you don't have the SSL development dependencies installed on your system.
Install the following dependency, and then re-configure and re-compile Python 3.5.
Ubuntu
apt-get install libssl-dev
In addition it is recommended to install the following.
apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libsqlite3-dev
CentOS
yum install openssl-devel
In addition it is recommended to install the following.
yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel
Please note that besides that as of version OpenSSL 1.1.0 (included from Ubuntu 18.04 repositories, I am not sure for other Linux distributions) there are python vesions that may have compilation issues (see this question and my answer), in short:
Python <3.4.5 and Python <3.5.3 have not implemented this newest version of OpenSSL, most likely other major Python versions suffer the same issue. The fix is to download the minor version that implements the fix (or newer). Check the full changelogs to check which minor version that is (changelog for 3.4 and 3.5)
On Ubuntu 18.04 only this worked for me
sudo apt-get install libssl1.0
CentOS:
If you didn't have openssl-devel at the time of installing python, pip 8.1.1 won't install.
After installing openssl-devel, reinstall python.
This time it should install pip just file.
I tried to install Python 3.4.10 using asdf but got following error:
$ asdf install python 3.4.10
python-build 3.4.10 /home/br0ke/.asdf/installs/python/3.4.10
Downloading Python-3.4.10.tar.xz...
-> https://www.python.org/ftp/python/3.4.10/Python-3.4.10.tar.xz
Installing Python-3.4.10...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems
BUILD FAILED (Fedora 30 using python-build 1.2.15-2-g22c02022)
Inspect or clean up the working tree at /tmp/python-build.20191121110112.9959
Results logged to /tmp/python-build.20191121110112.9959.log
Last 10 log lines:
(cd /home/br0ke/.asdf/installs/python/3.4.10/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS
It may mean that I have too fresh OpenSSL version installed in my system and this version is not supported by Python I'm trying to build. I managed to install Python 3.4.10 on my Fedora 30 machine (has OpenSSL 1.1+ by default) using the following steps:
Temporary remove openssl-devel if it is installed as it will conflict with older version:
$ sudo dnf remove openssl-devel
Install compat OpenSSL 1.0 packages:
$ sudo dnf install compat-openssl10 compat-openssl10-devel
Build Python 3.4.10 (I use asdf but it should work with pyenv as well):
$ asdf install python 3.4.10
Remove compat library and install modern instead to be able to build something more fresh next time:
$ sudo dnf remove compat-openssl10-devel
$ sudo dnf install openssl-devel
Inspired by this workaround with help from Fedora community people.
If you use Manjaro Linux, you can use this:
sudo pacman -S openssl , check
If you are using RedHat Enterprise Linux, you can use this:
yum install openssl-devel -y
CentOS or RHEL machine Python3(3.7.0) ssl not supported as of now.
pip installation supported with Python <=3.6

Installing distribute in Python 3.3 Ubuntu

I am running Ubuntu 12.04 and I have a distribution of Python 3.3.1 installed. I want to install some packages, so I first sought to install distribute-0.6.38. During the "install" phase, I am encountering the following runtime error ($HOME is the location of my Python3.3 installation):
File "$HOME/Python-3.3.1/Lib/zipfile.py", line 583, in _check_compression
"Compression requires the (missing) zlib module"
RuntimeError: Compression requires the (missing) zlib module
I tracked back through the files and function calls, but cannot tell why the creation of the zipfile (I assume this is the root of the error) failed.
Is there something missing from the package? Or is there an issue with the fact that this is a secondary installation of Python?
It is an issue with the fact you installed Python from source.
You need to install the zlib1g-dev package to provide the headers to Python to be able to compile in zlib support:
sudo apt-get install zlib1g-dev
You may be missing other dependencies; here is a list of packages I'd install if I were to compile Python on an Ubuntu machine:
build-essential
libbz2-dev
libncursesw5-dev
libreadline5-dev
libssl-dev
libgdbm-dev
libc6-dev
libsqlite3-dev
tk-dev
You need to have the zlib1g-dev library installed.
Try
sudo apt-get install zlib1g-dev
and reinstall.
If that doesn't work you may need to specify where zlib installs like so;
python setup.py install

Categories