运行mark2来监督我的Minecraft服务器和我升级到Ubuntu 16 LTS似乎有点麻烦,我无法想出如何修复它。可以说mark2似乎需要PyOpenSSL 0.13,而且升级似乎迫使python升级到自己的dist包PyOpenSSL0.15.1
使用mark2 start时给出的错误是:

Traceback (most recent call last):
  File "/usr/local/bin/mark2", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
    @_call_aside
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 637, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 650, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 829, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pyOpenSSL==0.13' distribution was not found and is required by mark2

尝试使用pippip install pyopenssl==0.13会产生这种可怕的效果:
Collecting pyopenssl==0.13
  Using cached pyOpenSSL-0.13.tar.gz
Building wheels for collected packages: pyopenssl
  Running setup.py bdist_wheel for pyopenssl ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-Dt9RiD/pyopenssl/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpsbnZGjpip-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/OpenSSL
  copying OpenSSL/__init__.py -> build/lib.linux-x86_64-2.7/OpenSSL
  copying OpenSSL/tsafe.py -> build/lib.linux-x86_64-2.7/OpenSSL
  copying OpenSSL/version.py -> build/lib.linux-x86_64-2.7/OpenSSL
  creating build/lib.linux-x86_64-2.7/OpenSSL/test
  copying OpenSSL/test/__init__.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
  copying OpenSSL/test/util.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
  copying OpenSSL/test/test_crypto.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
  copying OpenSSL/test/test_rand.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
  copying OpenSSL/test/test_ssl.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
  running build_ext
  building 'OpenSSL.crypto' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/OpenSSL
  creating build/temp.linux-x86_64-2.7/OpenSSL/crypto
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/crypto.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/crypto.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509name.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509name.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/pkey.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/pkey.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509store.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509store.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509req.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509req.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509ext.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509ext.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/pkcs7.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/pkcs7.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/pkcs12.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/pkcs12.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/netscape_spki.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/netscape_spki.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/revoked.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/revoked.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/crl.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/crl.o
  OpenSSL/crypto/crl.c:6:23: error: static declaration of ‘X509_REVOKED_dup’ follows non-static declaration
   static X509_REVOKED * X509_REVOKED_dup(X509_REVOKED *orig) {
                         ^
  In file included from /usr/include/openssl/ssl.h:156:0,
                   from OpenSSL/crypto/x509.h:17,
                   from OpenSSL/crypto/crypto.h:30,
                   from OpenSSL/crypto/crl.c:3:
  /usr/include/openssl/x509.h:751:15: note: previous declaration of ‘X509_REVOKED_dup’ was here
   X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);
                 ^
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for pyopenssl
  Running setup.py clean for pyopenssl
Failed to build pyopenssl
Installing collected packages: pyopenssl
  Running setup.py install for pyopenssl ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-Dt9RiD/pyopenssl/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mnXvzL-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    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/OpenSSL
    copying OpenSSL/__init__.py -> build/lib.linux-x86_64-2.7/OpenSSL
    copying OpenSSL/tsafe.py -> build/lib.linux-x86_64-2.7/OpenSSL
    copying OpenSSL/version.py -> build/lib.linux-x86_64-2.7/OpenSSL
    creating build/lib.linux-x86_64-2.7/OpenSSL/test
    copying OpenSSL/test/__init__.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
    copying OpenSSL/test/util.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
    copying OpenSSL/test/test_crypto.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
    copying OpenSSL/test/test_rand.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
    copying OpenSSL/test/test_ssl.py -> build/lib.linux-x86_64-2.7/OpenSSL/test
    running build_ext
    building 'OpenSSL.crypto' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/OpenSSL
    creating build/temp.linux-x86_64-2.7/OpenSSL/crypto
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/crypto.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/crypto.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509name.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509name.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/pkey.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/pkey.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509store.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509store.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509req.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509req.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/x509ext.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/x509ext.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/pkcs7.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/pkcs7.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/pkcs12.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/pkcs12.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/netscape_spki.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/netscape_spki.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/revoked.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/revoked.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c OpenSSL/crypto/crl.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/crl.o
    OpenSSL/crypto/crl.c:6:23: error: static declaration of ‘X509_REVOKED_dup’ follows non-static declaration
     static X509_REVOKED * X509_REVOKED_dup(X509_REVOKED *orig) {
                           ^
    In file included from /usr/include/openssl/ssl.h:156:0,
                     from OpenSSL/crypto/x509.h:17,
                     from OpenSSL/crypto/crypto.h:30,
                     from OpenSSL/crypto/crl.c:3:
    /usr/include/openssl/x509.h:751:15: note: previous declaration of ‘X509_REVOKED_dup’ was here
     X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);
                   ^
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-Dt9RiD/pyopenssl/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mnXvzL-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-Dt9RiD/pyopenssl/
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

所以在这一点上我不知所措,因为我不知道从这里走到哪里。升级pip也失败了,并停留在8.1.1,尽管我不认为这是我真正的问题。有什么想法吗?

最佳答案

下面的补丁对我很好(pyOpenSSL==0.12/0.13)

pip download pyOpenSSL==0.13
tar xzf pyOpenSSL-0.13.tar.gz
cd pyOpenSSL-0.13

wget https://gist.githubusercontent.com/brycepg/809501ae24e34e9fdb58a7932c12287b/raw/74e0165e73dadab8051a9041bcb8e657705a706b/fix.patch

patch OpenSSL/crypto/crl.c fix.patch
pip install --no-clean .

您可以在https://github.com/pyca/pyopenssl/issues/276

关于python - Ubuntu Server 16无法安装(降级)到PyOpenSSL 0.13,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39208269/

10-14 13:14