11

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?

martineau
  • 112,593
  • 23
  • 157
  • 280
ohadshay
  • 187
  • 1
  • 2
  • 14
  • 1
    Just to make sure: are you certain that you are invoking `Python 2.x` ? Ubuntu 18.04 has `3.x` as default, so make sure that you are not accidentally starting the script using another python version – Ralf Jan 16 '19 at 13:15
  • Checking, but main run perfect, while jenkinsRun does not. – ohadshay Jan 16 '19 at 13:31
  • you were right! The pycharm interpettor was /usr/bin/python which is ok, but when it call os.system('python main bla bla ..) it pointed to /usr/local/bin/python.Thank a lot .BTW -how can i close this question – ohadshay Jan 16 '19 at 16:50

8 Answers8

15

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

sudo pip install awscli --ignore-installed six
3

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.

Ralf
  • 14,947
  • 4
  • 39
  • 61
3

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.

Guido
  • 5,244
  • 1
  • 25
  • 46
0

I was working in PyCharm when I hit this wall.

Solved it by redirecting the path to my Anaconda environment, which I keep better provisioned and up to date.

Select Edit Configurations

enter image description here

leerssej
  • 12,592
  • 5
  • 45
  • 53
0

Update the latest version of awscli resolved on my Mac by the below command line.

curl "https://awscli.amazonaws.com/AWSCLIV2-2.0.30.pkg" -o

"AWSCLIV2.pkg" sudo installer -pkg AWSCLIV2.pkg -target /

Reference:

https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html#cliv2-mac-install-cmd

Long Nguyen
  • 8,300
  • 3
  • 43
  • 48
0

After uninstalling, installing, even creating environments... this worked for me!

https://stackoverflow.com/a/60405693

PhilGa
  • 1
0

In my case this issue came apparently from having colliding versions of boto3, botocore and awscli. This fixed the issue in my case:

pip install boto3 botocore awscli aiobotocore --ignore-installed
ronkov
  • 800
  • 5
  • 11
-1

I am not sure why it worked. But, I had this issue in AWS Glue, and I was able to get around this problem by using Glue 3.0 instead of Glue 2.0.

Jeong Kim
  • 429
  • 2
  • 9
  • 20