【发布时间】:2019-06-10 13:03:27
【问题描述】:
我的资源:
Python 2.7、Ubunutu 18.04、Pycharm、虚拟机甲骨文
我有一个用 python 构建的自动化解决方案。
当然,该解决方案可以从cmd 或pycharm 运行。
运行自动化解决方案的 2 个选项。
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)
一旦jenkinsRun.py 运行,它将像这样执行每个main.py:
os.system('python main.py %s %s %s %s %s %s'%(STD,config.VpcStackName, '-dryrun', 'false', '-tenant' ,config.PROD_STAGE_Tenant))
请注意,这是我 3 年前实现它的方式..可能是更好的方法,例如使用 __import__,但需要传递参数的方法等...
无论如何,运行时:
python main.py arg a,b,c..
一切都好。
运行时:
jenkinsRun.py
每次使用 diff args 都应该运行 main 我得到异常:
"/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
仅当我在新环境中运行代码时才会发生这种情况(请参阅上面的资源) 上周我有一个带有 ubuntu 15.04(旧)的旧 virtul 盒子,一切正常(从那以后就没有碰过vode)。
我已经从头开始在新的虚拟机上安装了库、驱动程序等。
有什么想法吗?
【问题讨论】:
-
只是为了确保:您确定您正在调用
Python 2.x吗? Ubuntu 18.04 默认使用3.x,因此请确保您不会意外使用另一个 python 版本启动脚本 -
正在检查,但主要运行完美,而 jenkinsRun 没有。
-
你是对的! pycharm 解释器是 /usr/bin/python 没问题,但是当它调用 os.system('python main bla bla ..) 它指向 /usr/local/bin/python。非常感谢.BTW - 怎么能我关闭这个问题
标签: python python-2.7