Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

from urllib3.util.ssl_ import ( ImportError: cannot import name ssl

My resources:

Python 2.7, Ubunutu 18.04, Pycharm, virtual box oracle

I have an automation solution built in python. The solution can be run from both cmd or pycharm of course. 2 options to run automation solution.

python main.py args a,b,c...(run 1 suite of tests)
python jenkinsRun.py arg a,b,c...(run main.py with diff args each time -lets say 5 time for instance)

Once jenkinsRun.py is runnig it will execute each main.py like this:

os.system('python main.py %s %s %s %s %s %s'%(STD,config.VpcStackName, '-dryrun', 'false', '-tenant' ,config.PROD_STAGE_Tenant))

Note that this is how I implemented it 3 years ago..could be better ways like using __import__, but need way to pass arguments, etc...

Anyway, when run:

python main.py arg a,b,c..

All good.

When run:

jenkinsRun.py

which should run main each time with diff args I get exception:

"/home/ohad/.local/lib/python2.7/site-packages/botocore/httpsession.py", line 7, in <module>
    from urllib3.util.ssl_ import (
ImportError: cannot import name ssl

This happend only when I run the code on my new environment (see resources above) last week I had old virtul box with ubuntu 15.04 (old) which everything worked well (didn't touch the vode ever since).

I have installed on new virtual box from scratch libaries, drivers, etc, etc.

Any ideas?

like image 569
ohadshay Avatar asked Jan 16 '19 12:01

ohadshay


3 Answers

Could be some issue with installation. I did re-installed on MAC and it worked

sudo pip install awscli --ignore-installed six
like image 63
Phani Kiran Mullapudi Avatar answered Nov 20 '22 16:11

Phani Kiran Mullapudi


I had a similar error after creating a new environment (which also uses Boto3). It turned out to be a DLL error (ImportError: DLL load failed), which was caught by SSL module resulting in the error from the question: ImportError: cannot import name ssl.

Solution for me was to add an additional folder to the path: path_to_anaconda/Anaconda3/Library/bin. In that way, DLL load succeeds and the given ImportError is resolved.

like image 26
Guido Avatar answered Nov 20 '22 15:11

Guido


Just to make sure: are you certain that you are invoking Python 2.x ?

Ubuntu 18.04 has Python 3.x as default, so make sure that you are not accidentally starting the script using another python version.

like image 3
Ralf Avatar answered Nov 20 '22 16:11

Ralf