在Ubuntu 14.04.4 LTS Vagrant Box上安装JPype 1-0.6.1错误

时间:2016-05-19 10:59:10

标签: python python-2.7 gcc ubuntu-14.04 jpype

我一直在寻找可能的解决方案,似乎已经用光了。我正在尝试安装JPype,因为我需要它来为这个锅炉管道包...

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

...支持本教程https://github.com/ptwobrussell/Mining-the-Social-Web-2nd-Edition

...但我一直收到以下错误。我已尝试安装从pypi下载的.tar.gz和Github repo,但仍然会收到错误。

FYI

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

我正在使用Ubuntu 14.04.4 LTS Vagrant Box,运行带有虚拟python 2.7.11环境的Anaconda Python(因此输出开头的(python2))。我在这里仍然是一个新手,所以任何指针都会非常感激。

错误输出

(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/

2 个答案:

答案 0 :(得分:0)

我被置于Github的正确道路上。总而言之,因为我使用的是Anaconda虚拟环境,所以它在Anaconda而不是Ubuntu下寻找gcc。

这可以使用which gcc确定,如果使用Ubuntu系统gcc,则应返回/usr/bin/gcc,但我的返回/home/vagrant/anaconda2/envs/python2/bin/gcc

最初我认为我需要覆盖它以将其指向系统gcc,但是通过首先确保我在Anaconda虚拟环境中运行,然后

,它很容易解决
conda install gcc

之后,Jpype安装得很好。

答案 1 :(得分:0)

我在2019年面临同样的问题,我做了以下工作: 二进制安装: 从conda-forge软件频道进行安装:

conda install -c conda-forge jpype1

对我有用。

相关问题