使用 pip3 install python-jenkins 后在 pycharm 中使用,运行以后报错,但是在命令行使用就没问题,已经确认 pycharm 环境中有 python-jenkins

import jenkins
jenkins_server_url='http://localhost:8080'
user_id='admin'
api_token='admin'
server = jenkins.Jenkins('http://localhost:8080', username=user_id, password=api_token)

Traceback (most recent call last):
  File "/Users/xxxx/PycharmProjects/untitled/jenkins.py", line 3, in <module>
    import jenkins
  File "/Users/xxxx/PycharmProjects/untitled/jenkins.py", line 16, in <module>
    server = jenkins.Jenkins('http://localhost:8080', username=user_id, password=api_token)
AttributeError: module 'jenkins' has no attribute 'Jenkins'


↙↙↙阅读原文可查看相关链接,并与作者交流