Skip to content

The problem to install jpype and to work with python-graphite in ubuntu #3

@GoogleCodeExporter

Description

@GoogleCodeExporter
  Finally I have this problem solved,and now I put my solution here.
My operation system is ubuntu 11.10,which does not installed jdk.So,at first 
you should install one jdk.It is easy to install with apt-get.I installed 
open-6-jdk.And the problem is that ubuntu does not set the JAVA_HOME in 
CLASSPATH automatically which trouble me so much.
  Now is the time to set the JAVA_HOME.sudo gedit /etc/environment
,opening the file to set CLASSPATH.Below is the mine:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/u
sr/lib/jvm/java-6-openjdk/bin"
CLASSPATH=".:/usr/lib/jvm/java-6-openjdk/lib"
JAVA_HOME="/usr/lib/jvm/java-6-openjdk"
Just append " :/usr/lib/jvm/java-6-openjdk/bin " to the "PATH" if yours already 
have "PATH" .
And then,put this to the terminal:sudo update-alternatives --config java
  This command is to choose  one of the jdks that you have installed as default.For me ,there are two java-6-openjdk ,and I choose the second one.
  It is not enough now if you do not set CLASSPATH in ~/.bashrc,and it will cause the error below:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/graphite/rdfgraph.py", line 215, in __init__
    engine = self.create_default_engine()
  File "/usr/local/lib/python2.7/dist-packages/graphite/rdfgraph.py", line 227, in create_default_engine
    return JenaGraph()
  File "/usr/local/lib/python2.7/dist-packages/graphite/rdfgraph.py", line 1371, in __init__
    super(JenaGraph, self).__init__(**k)
  File "/usr/local/lib/python2.7/dist-packages/graphite/rdfgraph.py", line 1316, in __init__
    runJVM()
  File "/usr/local/lib/python2.7/dist-packages/graphite/rdfgraph.py", line 1245, in runJVM
    jvm_file = jpype.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
    return _linux.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
    jvm = _getJVMFromJavaHome()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
    if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

  Then open ~/.bashrc: gedit ~/.bashrc
and put these in the end of it:
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export CLASSPATH=.:$JAVA_HOME/lib  
 and now put the command to terminal : source ~/.bashrc
 The jpype works weak in Linux,if you have not hard coded in the JAVA_HOME ,during your install,and error occur:

error: command 'gcc' failed with exit status 1

 So you should open the setup.py,and find "def setupLinux(self):"
 and change the line:" self.javaHome = '/usr/lib/jvm/java-1.5.0-sun-1.5.0.08' # Ubuntu linux" ,set the javaHome to your default jdk,for example:self.javaHome = '/usr/lib/jvm/java-6-openjdk/' # Ubuntu linux.
 Now all will be ok!
 Sorry for my poor English,and wish to make me clear!
 Any problem with installing jpype and python-graphite can contact me by shahuwang@qq.com.

Original issue reported on code.google.com by shahuwa...@gmail.com on 24 Mar 2012 at 6:33

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions