How to use ssl in python 2.7 - python-2.7

I am using python 2.7 and i need secure url with ssl protocol(HTTPS).Can we do this in python 2.7
when i trying to import ssl i m getting the following error
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib64/python2.7/ssl.py", line 60, in
import _ssl # if we can't import it, let the error propagate
ImportError: /usr/lib64/python2.7/lib-dynload/_ssl.so: symbol SSLeay_version, version OPENSSL_1.0.1 not defined in file libcrypto.so.10 with link time reference.
Please help me if anybody know...Thanks in advance

I got Answer
I have re-installed openssl
This is the code i used in terminal
sudo yum install openssl-devel

Related

error when importing jwcrypto in python2.7

I am using jwcrypto in python2.7, and here comes a problem.
>>> import jwcrypto
>>> from jwcrypto import jwk, jws
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Lsq\.conda\envs\py27\lib\site-packages\jwcrypto\jwk.py", line 318
raise InvalidJWKType(kty) from e
^
SyntaxError: invalid syntax
I am not familiar with python2.7, and it seems like it is not allowed to use raise from in python2.7.
However, in jwk.py i found several raise from which cause the error above. I installed python2.7 via conda create -n py27 python=2.7, and installed jwcrypto via pip install jwcrypto.
Does anyone know how may this problem be solved?
Uninstall 1.0 version and install 0.9.1 version for jwcrypto in python 2.7.
pip install jwcrypto==0.9.1

how to install the ssl module for python 2.7.17 on opensuse (SLES) 15 SP2?

I have installed OpenSSL and python2-pyOpenSSL-17.5.0-lp152.6.2.noarch.rpm in my SLES machine and still, I am getting the following error:
import ssl inside python CLI
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named ssl
pip install numpy gives the following error:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Can anyone help me with this?
You may need to install libopenssl-devel package

pip: ImportError: No module named retrying

I'm trying to create a new environment and install various 3rd party packages on an Ubuntu machine. After having to install condo (for a matplotlib installation) and gdal, the pip function no longer works. Instead I receive:
Traceback (most recent call last):
File "/media/imagery/ENVIRONMENTS/Project_1/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 14, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python2.7/dist-packages/pip/utils/__init__.py", line 30, in <module>
from pip._vendor.retrying import retry
ImportError: No module named retrying
I've called pip both in and outside my environment, and still observe the same issue. Also I've tried a pip install --upgrade pip and still retrieve the same Traceback. Any ideas how to resolve this?
As a cheap workaround, export PYTHONPATH=" " seemed to work for now in order to install other packages, but as soon as I need the gdal package, I have to then set PYTHONPATH again.
I had a similar exception and could manage to repair it.
In my case I upgraded Ubuntu 16.04 to Ubuntu 18.04.
I had to re-create the virtualenv. Depending on your choice:
virtualenv .
Or
virtualenv --system-site-packages .

Import Error: No Module named ldap, issues with python-ldap module installation on mac os Serira, python 2.7

Running a simple standalone python script on mac os Sierra. I am getting the following error:
Traceback (most recent call last):
File "user_exists.py", line 4, in <module>
import ldap
ImportError: No module named ldap
I went and tried installing using pip the module, I get the following output:
$sudo -H pip install
Requirement already satisfied: python-ldap in /usr/local /bin/python_ldap-2.4.28-py2.7-macosx-10.12-intel.egg
Requirement already satisfied: setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from python-ldap)
I tried testing:
$ python -c "import ldap"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named ldap
Please suggest whats the best approach to solve this issue?

pip install django-twilio Error installation

Trying to install django-twilo using pip on ubuntu machine
Getting error
referring doc
workspace/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/home/rahul/workspace/repository/inteliexam_workspace/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Using cached django_twilio-0.8.0-py2.py3-none-any.whl
Collecting django-phonenumber-field>=0.6 (from django-twilio)
Using cached django-phonenumber-field-1.3.0.tar.gz
Could not import setuptools which is required to install from a source distribution.
Traceback (most recent call last):
File "/home/rahul/workspace/repository/inteliexam_workspace/local/lib/python2.7/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/home/rahul/workspace/repository/inteliexam_workspace/local/lib/python2.7/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/home/rahul/workspace/repository/inteliexam_workspace/local/lib/python2.7/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/home/rahul/workspace/repository/inteliexam_workspace/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 70, in <module>
import packaging.version
ImportError: No module named packaging.version
You have a typo. It is django-twilio, not django-twillio
The right command that you should use, as you can see from the doc is
pip install django-twilio
and not
pip install django-twillio
EDIT
To fix your problem you can run this command
pip install -U setuptools
and after run again
pip install django-twilio