XX-net / XX-Net

A proxy tool to bypass GFW.
32.98k stars 7.7k forks source link

import build-in openssl fail:ImportError('No module named pycparser',) #12761

Open yrong opened 4 years ago

yrong commented 4 years ago

➜ XX-Net-3.13.3 lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.3 LTS Release: 18.04 Codename: bionic

➜ XX-Net-3.13.3 which python /home/ronyang/.pyenv/shims/python ➜ XX-Net-3.13.3 python --version Python 2.7.14

➜ XX-Net-3.13.3 ./start XX-Net version:3.13.3 Installing pyOpenSSL for your system... Please type in your password if requested 正在读取软件包列表... 完成 正在分析软件包的依赖关系树
正在读取状态信息... 完成
python-openssl 已经是最新版 (17.5.0-1ubuntu1)。 python-pycparser 已经是最新版 (2.18-2)。 升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 10 个软件包未被升级。 2019-09-18 09:44:08.307 [launcher][INFO] import build-in openssl fail:ImportError('No module named pycparser',) 2019-09-18 09:44:08.310 [launcher][ERROR] import system python-OpenSSL fail:ImportError('No module named pycparser',) 2019-09-18 09:44:08.311 [launcher][ERROR] Except stack:Traceback (most recent call last): File "code/default/launcher/start.py", line 177, in import OpenSSL File "/ssd/XX-Net-3.13.3/code/default/python27/1.0/lib/noarch/OpenSSL/init.py", line 8, in from OpenSSL import rand, crypto, SSL File "/ssd/XX-Net-3.13.3/code/default/python27/1.0/lib/noarch/OpenSSL/rand.py", line 12, in from OpenSSL._util import ( File "/ssd/XX-Net-3.13.3/code/default/python27/1.0/lib/noarch/OpenSSL/_util.py", line 6, in from cryptography.hazmat.bindings.openssl.binding import Binding File "/ssd/XX-Net-3.13.3/code/default/python27/1.0/lib/linux/cryptography/hazmat/bindings/openssl/binding.py", line 60, in class Binding(object): File "/ssd/XX-Net-3.13.3/code/default/python27/1.0/lib/linux/cryptography/hazmat/bindings/openssl/binding.py", line 109, in Binding libraries=_get_libraries(sys.platform) File "/ssd/XX-Net-3.13.3/code/default/python27/1.0/lib/linux/cryptography/hazmat/bindings/utils.py", line 97, in build_ffi_for_binding extra_link_args=extra_link_args, File "/ssd/XX-Net-3.13.3/code/default/python27/1.0/lib/linux/cryptography/hazmat/bindings/utils.py", line 105, in build_ffi ffi = FFI() File "/ssd/XX-Net-3.13.3/code/default/python27/1.0/lib/linux/cffi/api.py", line 52, in init from . import cparser, model File "/ssd/XX-Net-3.13.3/code/default/python27/1.0/lib/linux/cffi/cparser.py", line 6, in import pycparser ImportError: No module named pycparser

Try install python-openssl

Press Enter to continue...

yrong commented 4 years ago

should manually run pip install pycparser before start

SeaHOH commented 4 years ago

你的日志顺序是不是有点问题,XX-Net 是运行了第二次吗?

yrong commented 4 years ago

啥问题,缺个依赖

SeaHOH commented 4 years ago

不,可能是加载顺序的问题,不过之前也没见有人提这个。

yrong commented 4 years ago

should manually run pip install pycparser before start 反正我这里加了依赖就好使了

SeaHOH commented 4 years ago

https://github.com/XX-net/XX-Net/blob/c6165214f91ec2ee7204b43d1256c101903f63be/code/default/launcher/start.py#L165-L182

~我的意思是 L177 这里没有恢复 L166 改变的加载顺序,如果恢复了,按照提示安装 python-openssl 后可能 (没条件测试) 就不需要 pycparser,但是现在它还是尝试加载内置模块。~

看漏了 L171。。。

yrong commented 4 years ago

should consider about how to work with multiple python env management tool like pyenv or virtualenv

➜ XX-Net-3.13.3 which python /home/ronyang/.pyenv/shims/python

https://github.com/XX-net/XX-Net/blob/c6165214f91ec2ee7204b43d1256c101903f63be/start#L76-L105

fixed by manually running pip install pyopenssl first

SeaHOH commented 4 years ago

这个不是我考虑的事情,实际上现在可以说是无人维护了,只是有些时候实在看不惯才会改一些东西,或者是填自己以前挖的一些坑。

yrong commented 4 years ago

https://github.com/XX-net/XX-Net/pull/12772

提交说明一下. ubuntu18.04是目前的稳定版本,缺省就是1.1.0的openssl, 而内建的pyOpenSSL库是16.0.0不兼容底层库. 你start脚本里apt install只能安装到python系统环境里,pyenv当前环境还是加载不到就会导致重复安装, 加一个pip install安装到pyenv当前环境.