No module named ssl python

Содержание
  1. Saved searches
  2. Use saved searches to filter your results more quickly
  3. python — ImportError: No module named ‘_ssl’ #420
  4. python — ImportError: No module named ‘_ssl’ #420
  5. Comments
  6. When installing python3 and importing the ssl module, the following error is reported: ModuleNotFoundError: No module named ‘_ssl’
  7. Solution:
  8. 1. Install the dependency library:
  9. Second, install the new version of openssl
  10. 1. Download address of openssl installation package official website:
  11. 2. Set the environment variable LD_LIBRARY_PATH (general user environment variables can take effect, you can choose one of the two)
  12. (1) User environment variables:
  13. (2) System environment variables:
  14. 3. Unzip python3.7 and install it. Be sure to specify the 1.1.1 version of openssl you just installed! ! !
  15. Fourth, so far python3.7 is installed, let’s check whether the ssl module can be imported:
  16. 1. Create a python soft connection
  17. 2. Import the ssl module
  18. python3 (enter python3 command line)
  19. 3. Check the soft link of python.
  20. 5. Note 1: openssl or nginx offline installation of dependency libraries (offline or online if there is no network):
  21. (1) If yesOnline installationYou can install it directly with the yum command, depending on the successful installation.
  22. (2) If yesOffline installationJust download the following installation dependency package that I uploaded to Baidu Cloud, which contains the dependency package and openssl1.0.2 version.
  23. This offline package can also be used for nginx offline installation environment dependencies.
  24. в питон 3.2 нет ssl

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

python — ImportError: No module named ‘_ssl’ #420

python — ImportError: No module named ‘_ssl’ #420

Comments

Doing a fresh install of everything, getting critical errors trying to use python:
(openssl is installed — brew and system)

% brew install python3 % pip Traceback (most recent call last): File "/bio/linuxbrew/bin/pip", line 9, in load_entry_point('pip==6.1.1', 'console_scripts', 'pip')() File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 552, in load_entry_point File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2672, in load_entry_point File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2345, in load File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2351, in resolve File "/bio/linuxbrew/Cellar/python/2.7.10/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/__init__.py", line 15, in from pip.vcs import git, mercurial, subversion, bazaar # noqa File "/bio/linuxbrew/Cellar/python/2.7.10/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/vcs/mercurial.py", line 10, in from pip.download import path_to_url File "/bio/linuxbrew/Cellar/python/2.7.10/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/download.py", line 32, in from pip._vendor import requests, six File "/bio/linuxbrew/Cellar/python/2.7.10/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/_vendor/__init__.py", line 92, in load_module raise ImportError("No module named '%s'" % (name,)) ImportError: No module named 'pip._vendor.requests' 
% brew install python3 % pip3 Traceback (most recent call last): File "/bio/linuxbrew/bin/pip3", line 9, in load_entry_point('pip==6.1.1', 'console_scripts', 'pip3')() File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/setuptools-15.2-py3.4.egg/pkg_resources/__init__.py", line 552, in load_entry_point File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/setuptools-15.2-py3.4.egg/pkg_resources/__init__.py", line 2672, in load_entry_point File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/setuptools-15.2-py3.4.egg/pkg_resources/__init__.py", line 2345, in load File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/setuptools-15.2-py3.4.egg/pkg_resources/__init__.py", line 2351, in resolve File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/__init__.py", line 15, in from pip.vcs import git, mercurial, subversion, bazaar # noqa File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/vcs/mercurial.py", line 10, in from pip.download import path_to_url File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/download.py", line 32, in from pip._vendor import requests, six File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/_vendor/requests/__init__.py", line 59, in from .models import Request, Response, PreparedRequest File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/_vendor/requests/models.py", line 19, in from .packages.urllib3.fields import RequestField File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/_vendor/requests/packages/urllib3/__init__.py", line 10, in from .connectionpool import ( File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 31, in from .connection import ( File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/_vendor/requests/packages/urllib3/connection.py", line 45, in from .util.ssl_ import ( File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/_vendor/requests/packages/urllib3/util/__init__.py", line 5, in from .ssl_ import ( File "/bio/linuxbrew/opt/python3/lib/python3.4/site-packages/pip-6.1.1-py3.4.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py", line 12, in import ssl File "/bio/linuxbrew/opt/python3/lib/python3.4/ssl.py", line 97, in import _ssl # if we can't import it, let the error propagate ImportError: No module named '_ssl' 

The text was updated successfully, but these errors were encountered:

Читайте также:  Php date value now

Источник

When installing python3 and importing the ssl module, the following error is reported: ModuleNotFoundError: No module named ‘_ssl’

I tried a lot of articles with reference and found that it was not very useful. Finally, I found a solution and installed the dependencies of openssl.

Solution:

When centos installs python3.7, the minimum required openssl version is 1.0.2, but centos defaults to 1.0.1, so you need to update openssl again

1. Install the dependency library:

If there is a network, install the dependency library directly online. If the deployment environment does not have a network, you can refer to the last section, 5. Note 1: OpenSSL or nginx offline dependency installation process

Second, install the new version of openssl

Notice! The openssl configuration uses config instead of configure. In addition, the compilation and installation of openssl depends on the zlib dynamic library, so you must share zlib and go to the official website to check the latest version~

1. Download address of openssl installation package official website:

It can also be found in the last section of this article. Note 1: Download the openssl1.0.2 version as described in the steps, which can meet the Centos7.8 environment.

wget http://www.openssl.org/source/openssl-1.1.1.tar.gz (If you have a network, you can download it directly. If you don’t have a network, you need to download the installation package separately and upload it from windows to centos through terminal tools)

tar -zxvf openssl-1.0.2k.tar.gz (Unzip the corresponding version installation package)

cd openssl-1.0.2k (Go to the corresponding decompression directory)

./config –prefix=/usr/local/openssl shared zlib

(prefix is ​​the configuration installation directory, shared zlib installs dependent libraries) This step is the most important, must be shared

make && make install (compile, install)

2. Set the environment variable LD_LIBRARY_PATH (general user environment variables can take effect, you can choose one of the two)

This step is a must! ! The LD_LIBRARY_PATH environment variable is mainly used to specify paths other than the default path when looking for shared libraries (dynamic link libraries). When executing the function dynamic link .so, if the file is not in the default directory ‘/lib’ and ‘/usr/lib’, then you need to specify the environment variable LD_LIBRARY_PATH

Читайте также:  Compare enum and string java

(1) User environment variables:

echo “export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openssl/lib” >> /usr/local/.bash_profile(Add the environment variable of openssl in the user environment variable file)

source /usr/local/.bash_profile (reload the user environment variable file under this path)

Note: In the process of application on the actual server, it is found that this environment variable will only take effect in the current shell script. If the shell script is re-entered next time, it will be invalid. Therefore, if it is troublesome to use it every time the service is started, it can be set directly to the path environment. in the variable.(This step involves the usage habits of the Centos system. Generally, the program environment variable can be set into the user variable, and the path specifically saves the system variable, but the general user environment variable will be invalid, and the path will take effect globally).

(2) System environment variables:

If you choose to make it global, set the command in the path system environment variable as follows:

echo “export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openssl/lib” >> /etc/profile

(Add the environment variable of openssl to the system environment variable file)

source /etc/profile (Reload the system environment variable file under this path)

3. Unzip python3.7 and install it. Be sure to specify the 1.1.1 version of openssl you just installed! ! !

tar -zxvf Python-3.7.0.tgz (unzip the installation package)

./configure –prefix=/usr/local//python3 –with-openssl=/usr/local//openssl

(Configure the installation directory, specify the installation directory of the openssl environment)

make && make install (compile, install)

Fourth, so far python3.7 is installed, let’s check whether the ssl module can be imported:

1. Create a python soft connection

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip

(pip command line invocation points to pip3)

ln -s /usr/local/python3/bin/python3 /usr/bin/python

(The python command line call points to python3, if other versions of python are installed at the same time, you can specify the python version to use through this command)

ln -s /usr/local/python3/bin/python3 /usr/bin/python3

(python3 command line call points to python3, because some programs require python3 command call when executing, this step can be set as needed)

python –version

View the current python installation

2. Import the ssl module

python3 (enter python3 command line)

import ssl (import ssl module)

import _ssl (import _ssl module)

exit() (exit the python3 command line)

The whole process of solving the problem of ModuleNotFoundError: No module named ‘_ssl’ when Centos installs python3 and imports ssl above! ! !

Читайте также:  Java stream integer to string

5. Note 1: openssl or nginx offline installation of dependency libraries (offline or online if there is no network):

Step (1) online installation and step (2) offline installation, you can choose one of the two to install.

(1) If yesOnline installationYou can install it directly with the yum command, depending on the successful installation.

yum install -y zlib zlib-dev openssl-devel sqlite-devel bzip2-devel libffi libffi-devel gcc gcc-c++

(2) If yesOffline installationJust download the following installation dependency package that I uploaded to Baidu Cloud, which contains the dependency package and openssl1.0.2 version.

This offline package can also be used for nginx offline installation environment dependencies.

Installation package download method: Baidu Cloud, OpenSSL official website can be.

A. Link: https://pan.baidu.com/s/1mdwddtYEo-_qr3OUmBtxMw
Extraction code: qy2k

B. Downloading resources, point-free download has been set

C. The latest version of the openssl installation package can also be downloaded from the openssl official website.

(3) The dependency package is decompressed as follows:

The specific open folders are as follows:

The installation command is as follows:

rpm -ivh xxxx.rpm –nodeps

Command meaning comment: rpm -ivh (rpm package installation command), –nodeps skip environment dependencies

E.g:

rpm -ivh openssl-devel-1.0.2k-19.el7.x86_64.rpm –nodeps

Note: For learning only, record questions and reference, and encourage each other!

Reference article:

Источник

в питон 3.2 нет ssl

на vds ubuntu. поставил туда python 3.2, скачанный с python.org
import ssl ругается на отсутствие модуля
пробовал поставить openssl, пересобрать питон — бесполезно
на pypi.python.org есть ssl только для второй ветки

распаковал, запустил python3.2 setup.py install

. OpenSSL/crypto/crypto.c: In function 'locking_function': OpenSSL/crypto/crypto.c:741: error: 'CRYPTO_LOCK' undeclared (first use in this function) OpenSSL/crypto/crypto.c: In function 'init_openssl_threads': OpenSSL/crypto/crypto.c:758: warning: implicit declaration of function 'CRYPTO_num_locks' OpenSSL/crypto/crypto.c:765: warning: implicit declaration of function 'CRYPTO_set_id_callback' OpenSSL/crypto/crypto.c:766: warning: implicit declaration of function 'CRYPTO_set_locking_callback' OpenSSL/crypto/crypto.c: In function 'PyInit_crypto': OpenSSL/crypto/crypto.c:814: warning: implicit declaration of function 'ERR_load_crypto_strings' OpenSSL/crypto/crypto.c:815: warning: implicit declaration of function 'OpenSSL_add_all_algorithms' OpenSSL/crypto/crypto.c:848: error: 'X509_FILETYPE_PEM' undeclared (first use in this function) OpenSSL/crypto/crypto.c:849: error: 'X509_FILETYPE_ASN1' undeclared (first use in this function) OpenSSL/crypto/crypto.c:852: error: 'EVP_PKEY_RSA' undeclared (first use in this function) OpenSSL/crypto/crypto.c:853: error: 'EVP_PKEY_DSA' undeclared (first use in this function) error: command 'gcc' failed with exit status 1 

у меня нормально собралось с openssl-0.9.8q

попробуйте обновить openssl

openssl is already the newest version.

на vds ubuntu. поставил туда python 3.2, скачанный с python.org

Поздравляю, ты сделал через жопу. Что мешало поставить пакет?

import ssl ругается на отсутствие модуля

Ubuntu 10.04, пайтон из репозиториев:

# python3 Python 3.1.2 (r312:79147, Sep 27 2010, 09:57:50) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ssl >>> 

Источник

Оцените статью