Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import jenkins in python fails on mac

I installed the jenkins package on a mac using sudo easy_install python-jenkins. The installation went fine, no errors, but when I open python and type in import jenkins I get the following error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.7-intel/egg/jenkins.py", line 9, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
    return self._dlltype(name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Python/2.7/site-packages/lookup3.so, 6): image not found

Googling this did not yield any helpful result.

Traceback after Editing

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "jenkins.py", line 9, in <module>
    lookup3 = cdll.LoadLibrary(os.path.join(get_python_lib(), "lookup3.dynlib"))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
    return self._dlltype(name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Python/2.7/site-packages/lookup3.dynlib, 6): image not found
like image 773
cyberbemon Avatar asked Aug 31 '12 10:08

cyberbemon


People also ask

Is Python supported in Jenkins?

In the Python ecosystem there are tools which can be integrated into Jenkins for testing/reporting such as: nose2 and pytest for executing unit tests and generating JUnit-compatible XML test reports and Cobertura-compatible code coverage reports.

How do I import Jenkins into Python?

Example. JenkinsAPI is intended to map the objects in Jenkins (e.g. Builds, Views, Jobs) into easily managed Python objects: >>> import jenkinsapi >>> from jenkinsapi. jenkins import Jenkins >>> J = Jenkins('http://localhost:8080') >>> J.


1 Answers

The module in question isn't compatible with Mac OS X dynamic library conventions.

It tries to load a lookup3.so file, but on Mac it'll be lookup3.dynlib instead. You can verify this by looking at the /Library/Python/2.7/site-packages directory. Then just edit the jenkins.py module and replace the .so extension with .dynlib.

I'd also report this to the issue tracker of the module; a simple if platform.system() == 'Darwin': switch would keep things loadable across platforms.

Update: Actually, the module stubbornly expects the lookup3.so module to be located in the site-packages directory instead of with the module itself. It is thus not easy_install compatible. It'll work when you move all the files (unaltered) out of the .egg directory straight into your /Library/Python/2.7/site-packages/ directory.

like image 84
Martijn Pieters Avatar answered Oct 07 '22 20:10

Martijn Pieters