The pit that the Raspberry Pi 3b python3.6.1 SSL module cannot be called

I have been troubled by this problem for a long time. I uninstalled and installed various versions for countless times, but all ended in failure. I finally found a solution today to share.
The pre-order python is compiled and installed, and the various installations of pip are not described here, and go straight to the topic.

Check whether the SSL module is available, if an error is reported, try the following methods

1. Install openssl

sudo apt-get install openssl
sudo apt-get install libssl-dev
  • 1
  • 2

2. Change the Modules/Setup in the directory where the python source package is decompressed. Pay attention to the Setup file. This file will only be generated after python completes the installation.
Open the Setup file in edit mode, "CTRL+F", search for 'SSL', find the following code, delete # before lines 2-8, and exit and save.

# Socket module helper for socket(2)
_socket socketmodule.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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

Insufficient permissions to modify file permissions

$  sudo chmod 777 /home/pi/Python-3.6.1/Modules/Setup
  • 1

3. Recompile the file

$ cd Python-3.6.1 #Switch directory
$ sudo make #compile the file
  • 1
  • 2

Check to see if there are any errors

4. Installation

$ sudo make install 
  • 1

5. Check the SSL module

[email protected]:/home/pi/Python-3.6.1# python
Python 3.6.1 (default, Nov 12 2018, 10:13:29)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl  
>>>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

It can be used normally if successful.

If you have any questions, you can leave a message to exchange experience.

Tags: The pit that the Raspberry Pi 3b python3.6.1 SSL module cannot be called

python raspberry pie SSL

Related: The pit that the Raspberry Pi 3b python3.6.1 SSL module cannot be called