473,396 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Python,SWIG and libjvm

Hello,
I'm not sure if this the correct list but here goes (and sorry for the
noise). I've been attempting to wrap python around libhdfs.
So far so good (i've attached the SWIG template at the end). The
compilation works without errors and the shared objects do have
references to all the functions.

However, when importing into python

import pyhdfs

i get the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/home/sguha/tmp/b/hdfs.py", line 7, in ?
import _hdfs
ImportError: libjvm.so: cannot open shared object file: No such file
or directory

However, libjvm.so is located in /home/sguha/mine/jdk1.6.0_02/jre/lib/
amd64/server which is present in the PYTHONPATH and sys.path.
I can understand it complaining <i>while</iloading the libjvm.so
but python doesn't locate it even when in the path.

As an aside, the build command for hdfs.c has " -ljvm " - this
should affect SWIG, right? Meaning if my program (e.g) links to a
library and i want a wrapper around my program (to python) i need SWIG
templates for my headers only and not for the linked library...right?
( I guess the answer is i dont otherwise that would be quite a
nightmare of work)

Thank you for your time
Saptarshi
Attachments:
SWIG template
%module pyhdfs

%{
#include "hdfs.h"
%}

%include "hdfs.h"

Sep 20 '07 #1
3 2880
On Sep 20, 7:00 pm, sapsi <saptarshi.g...@gmail.comwrote:
Hello,
I'm not sure if this the correct list but here goes (and sorry for the
noise). I've been attempting to wrap python around libhdfs.
So far so good (

I should point out that libhdfs is a c library to Hadoop Distributed
FileSystem.
Thank you
Saptarshi
Sep 21 '07 #2
On Sep 20, 8:22 pm, sapsi <saptarshi.g...@gmail.comwrote:
On Sep 20, 7:00 pm, sapsi <saptarshi.g...@gmail.comwrote:
Hello,
I'm not sure if this the correct list but here goes (and sorry for the
noise). I've been attempting to wrap python around libhdfs.
So far so good (

I should point out that libhdfs is a c library to Hadoop Distributed
FileSystem.
Thank you
Saptarshi
Hmm,here goes, you need -Wl,--rpart -Wl,path-to-jvm in the LDFLAGS in
the compile process.
HTH
Saptarshi

Sep 21 '07 #3
On Sep 21, 9:00 am, sapsi <saptarshi.g...@gmail.comwrote:
Hello,
I'm not sure if this the correct list but here goes (and sorry for the
noise). I've been attempting to wrap python around libhdfs.
So far so good (i've attached the SWIG template at the end). The
compilation works without errors and the shared objects do have
references to all the functions.

However, when importing into python

import pyhdfs

i get the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/home/sguha/tmp/b/hdfs.py", line 7, in ?
import _hdfs
ImportError: libjvm.so: cannot open shared object file: No such file
or directory

However, libjvm.so is located in /home/sguha/mine/jdk1.6.0_02/jre/lib/
amd64/server which is present in the PYTHONPATH and sys.path.
I can understand it complaining <i>while</iloading the libjvm.so
but python doesn't locate it even when in the path.

As an aside, the build command for hdfs.c has " -ljvm " - this
should affect SWIG, right? Meaning if my program (e.g) links to a
library and i want a wrapper around my program (to python) i need SWIG
templates for my headers only and not for the linked library...right?
( I guess the answer is i dont otherwise that would be quite a
nightmare of work)

Thank you for your time
Saptarshi

Attachments:
SWIG template
%module pyhdfs

%{
#include "hdfs.h"
%}

%include "hdfs.h"
Your libjvm.so isn't being found because it isn't in a standard system
library directory. You have a few choices to solve this:

1. Install libjvm.so into /lib or /usr/lib. You may be able to get
away with putting it in /usr/local/lib if your OS is setup to look
there.

2. If a Linux/Solaris box, do:

LD_LIBRARY_PATH=/home/sguha/mine/jdk1.6.0_02/jre/lib/amd64/server
export LD_LIBRARY_PATH

then run your application. This will tell you application to look in
that directory for the shared library at run time.

3. If on Linux/Solaris, compile that library directory into the Python
module .so by setting before you compile your Python module:

LD_RUN_PATH=/home/sguha/mine/jdk1.6.0_02/jre/lib/amd64/server
export LD_RUN_PATH

This only needs to be done at compile time, but means your module will
always expect it to be in that location.

Graham

Sep 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Gary | last post by:
Hi- I've been searching the web for a while and I've been unable to find a way to access c data objects in python without using SWIG. I can do methods just fine but I can't access variables. ...
0
by: Jon Moldover | last post by:
Hi, I'm using Python in my win32 app by linking to the python23.dll. I'm trying to expose some c++ code in my app to Python so I can make application calls from Python scripts (according to the...
7
by: Bo Peng | last post by:
Dear Python group: I am planning on an application that involves several complicated C++ classes. Basically, there will be one or two big data objects and some "action" objects that can act on...
13
by: Roy Smith | last post by:
I've got a C library with about 50 calls in it that I want to wrap in Python. I know I could use some tool like SWIG, but that will give me a too-literal translation; I want to make some...
1
by: Arthur Chereau | last post by:
Hi, I'm trying to setup viewcvs to work with subversion 1.2.0 on Linux with Python 2.4.1. The last viewcvs (from CVS) needs subversion python bindings. I installed swig and built subversion from...
0
by: Claudio Grondi | last post by:
What is the current status of Python OpenCV interface i.e. the opencv module? \OpenCV\samples\python\contours.py gives following ERROR: OpenCV Python version of contours Traceback (most recent...
1
by: Java and Swing | last post by:
I am trying to wrap some C code I have. Currently I have something like... defs.h ----------- typedef unsigned long MY_DIGIT; myapp.c ------------- void MakeDigits(MY_DIGIT digits) {
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
6
by: matey | last post by:
I am have version 2.3.4. I want to write a python script to access a secure HTTPS. I tried the following: import urllib urllib.urlopen("https://somesecuresite.com") s = f.read() f.close()
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.