I am trying to use python to interact with jenkins.
Initially when I tried to import jenkinsapi
, I got the below ERROR.
>>> import jenkinsapi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/jenkinsapi-0.3.4/jenkinsapi/__init__.py", line 49, in <module>
from jenkinsapi import (
File "/root/jenkinsapi-0.3.4/jenkinsapi/api.py", line 15, in <module>
from jenkinsapi.jenkins import Jenkins
File "/root/jenkinsapi-0.3.4/jenkinsapi/jenkins.py", line 12, in <module>
from jenkinsapi.jobs import Jobs
File "/root/jenkinsapi-0.3.4/jenkinsapi/jobs.py", line 6, in <module>
from jenkinsapi.job import Job
File "/root/jenkinsapi-0.3.4/jenkinsapi/job.py", line 10, in <module>
from jenkinsapi.build import Build
File "/root/jenkinsapi-0.3.4/jenkinsapi/build.py", line 17, in <module>
import pytz
ImportError: No module named 'pytz'
Then I installed pytz
.
# yum install python34-pytz.noarch -y
Loaded plugins: product-id, rhnplugin, search-disabled-repos, subscription-manager
This system is receiving updates from RHN Classic or Red Hat Satellite.
Resolving Dependencies
--> Running transaction check
---> Package python34-pytz.noarch 0:2016.7-1.el7 will be installed
--> Processing Dependency: python(abi) = 3.4 for package: python34-pytz-2016.7-1.el7.noarch
--> Running transaction check
---> Package python34.x86_64 0:3.4.5-3.el7 will be installed
--> Processing Dependency: python34-libs(x86-64) = 3.4.5-3.el7 for package: python34-3.4.5-3.el7.x86_64
--> Processing Dependency: libpython3.4m.so.1.0()(64bit) for package: python34-3.4.5-3.el7.x86_64
--> Running transaction check
---> Package python34-libs.x86_64 0:3.4.5-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
python34-pytz noarch 2016.7-1.el7 epel 46 k
Installing for dependencies:
python34 x86_64 3.4.5-3.el7 epel 50 k
python34-libs x86_64 3.4.5-3.el7 epel 6.7 M
Transaction Summary
==============================================================================================================================================================================================================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 6.8 M
Installed size: 28 M
Downloading packages:
(1/3): python34-3.4.5-3.el7.x86_64.rpm | 50 kB 00:00:00
(2/3): python34-pytz-2016.7-1.el7.noarch.rpm | 46 kB 00:00:00
(3/3): python34-libs-3.4.5-3.el7.x86_64.rpm | 6.7 MB 00:00:01
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.2 MB/s | 6.8 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python34-3.4.5-3.el7.x86_64 1/3
Installing : python34-libs-3.4.5-3.el7.x86_64 2/3
Installing : python34-pytz-2016.7-1.el7.noarch 3/3
Verifying : python34-pytz-2016.7-1.el7.noarch 1/3
Verifying : python34-libs-3.4.5-3.el7.x86_64 2/3
Verifying : python34-3.4.5-3.el7.x86_64 3/3
Installed:
python34-pytz.noarch 0:2016.7-1.el7
Dependency Installed:
python34.x86_64 0:3.4.5-3.el7 python34-libs.x86_64 0:3.4.5-3.el7
Complete!
This resulted in successful import of jenkinsapi
root@dselilx6390 ~/jenkinsapi-0.3.4
# python3.4
Python 3.4.5 (default, Nov 9 2016, 16:24:59)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jenkinsapi
>>>
I was able to do a lot of work and then logged out of python CLI. I then logged back in and tried to import jenkinsapi
and then got the ERROR.
>>> import jenkinsapi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'jenkinsapi'
All of a sudden, its giving me an ImportError: No module named 'jenkinsapi'
error. I have not installed any packages or modified anything. What could have gone wrong ?