Search code examples
pythonpython-2.7gccubuntu-14.04jpype

JPype 1-0.6.1 install error on Ubuntu 14.04.4 LTS Vagrant Box


I've been looking all over for possible solutions and seem to have run out. I'm trying to install JPype as I need it for this boiler pipe package...

https://github.com/ptwobrussell/python-boilerpipe

...to support this tutorial https://github.com/ptwobrussell/Mining-the-Social-Web-2nd-Edition

...but I keep getting the error below. I've tried installing the .tar.gz downloaded from pypi, and the Github repo and still get the error.

FYI

echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64

I'm using an Ubuntu 14.04.4 LTS Vagrant Box, running Anaconda Python with a virtual python 2.7.11 environment (thus the (python2) at the start of the output). I'm still very much a newbie here so any pointers would be greatly appreciated.

Error output

(python2)vagrant@vagrant-ubuntu-trusty-64:~/Downloads$ pip install jpype1
Collecting jpype1
  Using cached JPype1-0.6.1.tar.gz
Building wheels for collected packages: jpype1
  Running setup.py bdist_wheel for jpype1 ... error
  Complete output from command /home/vagrant/anaconda2/envs/python2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-R2h1AL/jpype1/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpr6idxepip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/jpype
  copying jpype/_gui.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_jarray.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/reflect.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_jpackage.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_jwrapper.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_properties.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_darwin.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_jproxy.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_jobject.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_windows.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_core.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_jclass.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_jexception.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/nio.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/JClassUtil.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_jcollection.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_refdaemon.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_linux.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/__init__.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_pykeywords.py -> build/lib.linux-x86_64-2.7/jpype
  copying jpype/_jvmfinder.py -> build/lib.linux-x86_64-2.7/jpype
  creating build/lib.linux-x86_64-2.7/jpype/awt
  copying jpype/awt/__init__.py -> build/lib.linux-x86_64-2.7/jpype/awt
  creating build/lib.linux-x86_64-2.7/jpype/awt/event
  copying jpype/awt/event/__init__.py -> build/lib.linux-x86_64-2.7/jpype/awt/event
  copying jpype/awt/event/WindowAdapter.py -> build/lib.linux-x86_64-2.7/jpype/awt/event
  creating build/lib.linux-x86_64-2.7/jpypex
  copying jpypex/__init__.py -> build/lib.linux-x86_64-2.7/jpypex
  creating build/lib.linux-x86_64-2.7/jpypex/swing
  copying jpypex/swing/pyutils.py -> build/lib.linux-x86_64-2.7/jpypex/swing
  copying jpypex/swing/AbstractAction.py -> build/lib.linux-x86_64-2.7/jpypex/swing
  copying jpypex/swing/__init__.py -> build/lib.linux-x86_64-2.7/jpypex/swing
  running build_ext
  /tmp/pip-build-R2h1AL/jpype1/setup.py:147: FeatureNotice: Turned ON Numpy support for fast Java array access
    FeatureNotice)
  building '_jpype' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/native
  creating build/temp.linux-x86_64-2.7/native/python
  creating build/temp.linux-x86_64-2.7/native/common
  gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_NUMPY=1 -Inative/common/include -Inative/python/include -I/usr/lib/jvm/java-7-openjdk-amd64/include -I/usr/lib/jvm/java-7-openjdk-amd64/include/linux -I/home/vagrant/anaconda2/envs/python2/lib/python2.7/site-packages/numpy/core/include -I/home/vagrant/anaconda2/envs/python2/include/python2.7 -c native/python/py_monitor.cpp -o build/temp.linux-x86_64-2.7/native/python/py_monitor.o -ggdb
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
  In file included from native/python/include/jpype_python.h:24:0,
                   from native/python/py_monitor.cpp:17:
  native/common/include/jpype.h:63:0: warning: "PyUnicode_FromFormat" redefined [enabled by default]
       #define PyUnicode_FromFormat PyString_FromFormat
   ^
  In file included from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:85:0,
                   from native/python/include/jpype_python.h:23,
                   from native/python/py_monitor.cpp:17:
  /home/vagrant/anaconda2/envs/python2/include/python2.7/unicodeobject.h:277:0: note: this is the location of the previous definition
   # define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat
   ^
  In file included from /usr/include/stdio.h:934:0,
                   from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:33,
                   from native/python/include/jpype_python.h:23,
                   from native/python/py_monitor.cpp:17:
  /usr/include/bits/stdio.h: In function ‘__ssize_t getline(char**, size_t*, FILE*)’:
  /usr/include/bits/stdio.h:117:52: error: ‘__getdelim’ was not declared in this scope
     return __getdelim (__lineptr, __n, '\n', __stream);
                                                      ^
  In file included from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:38:0,
                   from native/python/include/jpype_python.h:23,
                   from native/python/py_monitor.cpp:17:
  /usr/include/string.h: At global scope:
  /usr/include/string.h:546:5: error: ‘__locale_t’ has not been declared
       __locale_t __loc)
       ^
  In file included from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/features.h:338:0,
                   from /usr/include/limits.h:25,
                   from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/limits.h:168,
                   from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/syslimits.h:7,
                   from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/limits.h:34,
                   from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:19,
                   from native/python/include/jpype_python.h:23,
                   from native/python/py_monitor.cpp:17:
  /usr/include/string.h:547:33: error: nonnull argument references non-pointer operand (argument 1, operand 3)
        __THROW __attribute_pure__ __nonnull ((1, 2, 3));
                                   ^
  In file included from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:38:0,
                   from native/python/include/jpype_python.h:23,
                   from native/python/py_monitor.cpp:17:
  /usr/include/string.h:550:18: error: ‘__locale_t’ has not been declared
        size_t __n, __locale_t __loc)
                    ^
  In file included from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/features.h:338:0,
                   from /usr/include/limits.h:25,
                   from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/limits.h:168,
                   from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/syslimits.h:7,
                   from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/limits.h:34,
                   from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:19,
                   from native/python/include/jpype_python.h:23,
                   from native/python/py_monitor.cpp:17:
  /usr/include/string.h:551:33: error: nonnull argument references non-pointer operand (argument 1, operand 4)
        __THROW __attribute_pure__ __nonnull ((1, 2, 4));
                                   ^
  In file included from /home/vagrant/anaconda2/envs/python2/gcc/include/c++/bits/localefwd.h:40:0,
                   from /home/vagrant/anaconda2/envs/python2/gcc/include/c++/string:43,
                   from native/common/include/jpype.h:68,
                   from native/python/include/jpype_python.h:24,
                   from native/python/py_monitor.cpp:17:
  /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h:52:23: error: ‘uselocale’ was not declared in this scope
     extern "C" __typeof(uselocale) __uselocale;
                         ^
  /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h:52:45: error: invalid type in declaration before ‘;’ token
     extern "C" __typeof(uselocale) __uselocale;
                                               ^
  /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h: In function ‘int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)’:
  /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h:75:53: error: ‘__gnu_cxx::__uselocale’ cannot be used as a function
       __c_locale __old = __gnu_cxx::__uselocale(__cloc);
                                                       ^
  /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h:100:33: error: ‘__gnu_cxx::__uselocale’ cannot be used as a function
       __gnu_cxx::__uselocale(__old);
                                   ^
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for jpype1
  Running setup.py clean for jpype1
Failed to build jpype1
Installing collected packages: jpype1
  Running setup.py install for jpype1 ... error
    Complete output from command /home/vagrant/anaconda2/envs/python2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-R2h1AL/jpype1/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-RtLlzc-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/jpype
    copying jpype/_gui.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_jarray.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/reflect.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_jpackage.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_jwrapper.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_properties.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_darwin.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_jproxy.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_jobject.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_windows.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_core.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_jclass.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_jexception.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/nio.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/JClassUtil.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_jcollection.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_refdaemon.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_linux.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/__init__.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_pykeywords.py -> build/lib.linux-x86_64-2.7/jpype
    copying jpype/_jvmfinder.py -> build/lib.linux-x86_64-2.7/jpype
    creating build/lib.linux-x86_64-2.7/jpype/awt
    copying jpype/awt/__init__.py -> build/lib.linux-x86_64-2.7/jpype/awt
    creating build/lib.linux-x86_64-2.7/jpype/awt/event
    copying jpype/awt/event/__init__.py -> build/lib.linux-x86_64-2.7/jpype/awt/event
    copying jpype/awt/event/WindowAdapter.py -> build/lib.linux-x86_64-2.7/jpype/awt/event
    creating build/lib.linux-x86_64-2.7/jpypex
    copying jpypex/__init__.py -> build/lib.linux-x86_64-2.7/jpypex
    creating build/lib.linux-x86_64-2.7/jpypex/swing
    copying jpypex/swing/pyutils.py -> build/lib.linux-x86_64-2.7/jpypex/swing
    copying jpypex/swing/AbstractAction.py -> build/lib.linux-x86_64-2.7/jpypex/swing
    copying jpypex/swing/__init__.py -> build/lib.linux-x86_64-2.7/jpypex/swing
    running build_ext
    /tmp/pip-build-R2h1AL/jpype1/setup.py:147: FeatureNotice: Turned ON Numpy support for fast Java array access
      FeatureNotice)
    building '_jpype' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/native
    creating build/temp.linux-x86_64-2.7/native/python
    creating build/temp.linux-x86_64-2.7/native/common
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_NUMPY=1 -Inative/common/include -Inative/python/include -I/usr/lib/jvm/java-7-openjdk-amd64/include -I/usr/lib/jvm/java-7-openjdk-amd64/include/linux -I/home/vagrant/anaconda2/envs/python2/lib/python2.7/site-packages/numpy/core/include -I/home/vagrant/anaconda2/envs/python2/include/python2.7 -c native/python/py_monitor.cpp -o build/temp.linux-x86_64-2.7/native/python/py_monitor.o -ggdb
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
    In file included from native/python/include/jpype_python.h:24:0,
                     from native/python/py_monitor.cpp:17:
    native/common/include/jpype.h:63:0: warning: "PyUnicode_FromFormat" redefined [enabled by default]
         #define PyUnicode_FromFormat PyString_FromFormat
     ^
    In file included from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:85:0,
                     from native/python/include/jpype_python.h:23,
                     from native/python/py_monitor.cpp:17:
    /home/vagrant/anaconda2/envs/python2/include/python2.7/unicodeobject.h:277:0: note: this is the location of the previous definition
     # define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat
     ^
    In file included from /usr/include/stdio.h:934:0,
                     from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:33,
                     from native/python/include/jpype_python.h:23,
                     from native/python/py_monitor.cpp:17:
    /usr/include/bits/stdio.h: In function ‘__ssize_t getline(char**, size_t*, FILE*)’:
    /usr/include/bits/stdio.h:117:52: error: ‘__getdelim’ was not declared in this scope
       return __getdelim (__lineptr, __n, '\n', __stream);
                                                        ^
    In file included from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:38:0,
                     from native/python/include/jpype_python.h:23,
                     from native/python/py_monitor.cpp:17:
    /usr/include/string.h: At global scope:
    /usr/include/string.h:546:5: error: ‘__locale_t’ has not been declared
         __locale_t __loc)
         ^
    In file included from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/features.h:338:0,
                     from /usr/include/limits.h:25,
                     from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/limits.h:168,
                     from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/syslimits.h:7,
                     from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/limits.h:34,
                     from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:19,
                     from native/python/include/jpype_python.h:23,
                     from native/python/py_monitor.cpp:17:
    /usr/include/string.h:547:33: error: nonnull argument references non-pointer operand (argument 1, operand 3)
          __THROW __attribute_pure__ __nonnull ((1, 2, 3));
                                     ^
    In file included from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:38:0,
                     from native/python/include/jpype_python.h:23,
                     from native/python/py_monitor.cpp:17:
    /usr/include/string.h:550:18: error: ‘__locale_t’ has not been declared
          size_t __n, __locale_t __loc)
                      ^
    In file included from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/features.h:338:0,
                     from /usr/include/limits.h:25,
                     from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/limits.h:168,
                     from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/syslimits.h:7,
                     from /home/vagrant/anaconda2/envs/python2/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed/limits.h:34,
                     from /home/vagrant/anaconda2/envs/python2/include/python2.7/Python.h:19,
                     from native/python/include/jpype_python.h:23,
                     from native/python/py_monitor.cpp:17:
    /usr/include/string.h:551:33: error: nonnull argument references non-pointer operand (argument 1, operand 4)
          __THROW __attribute_pure__ __nonnull ((1, 2, 4));
                                     ^
    In file included from /home/vagrant/anaconda2/envs/python2/gcc/include/c++/bits/localefwd.h:40:0,
                     from /home/vagrant/anaconda2/envs/python2/gcc/include/c++/string:43,
                     from native/common/include/jpype.h:68,
                     from native/python/include/jpype_python.h:24,
                     from native/python/py_monitor.cpp:17:
    /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h:52:23: error: ‘uselocale’ was not declared in this scope
       extern "C" __typeof(uselocale) __uselocale;
                           ^
    /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h:52:45: error: invalid type in declaration before ‘;’ token
       extern "C" __typeof(uselocale) __uselocale;
                                                 ^
    /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h: In function ‘int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)’:
    /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h:75:53: error: ‘__gnu_cxx::__uselocale’ cannot be used as a function
         __c_locale __old = __gnu_cxx::__uselocale(__cloc);
                                                         ^
    /home/vagrant/anaconda2/envs/python2/gcc/include/c++/x86_64-unknown-linux-gnu/bits/c++locale.h:100:33: error: ‘__gnu_cxx::__uselocale’ cannot be used as a function
         __gnu_cxx::__uselocale(__old);
                                     ^
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/home/vagrant/anaconda2/envs/python2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-R2h1AL/jpype1/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-RtLlzc-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-R2h1AL/jpype1/

Solution

  • I was put on the right path over at Github. To summarise, because I was using an Anaconda virtual environment it was looking for gcc under Anaconda rather than Ubuntu.

    This can be determined with which gcc which should return /usr/bin/gcc if using Ubuntu system gcc, but mine returned /home/vagrant/anaconda2/envs/python2/bin/gcc.

    Initially I thought I needed to override this to point it back to system gcc, but it was easily solved by first ensuring I was operating in the Anaconda virtual env, and then

    conda install gcc
    

    After that Jpype installed fine.