网上找了好半天 全是让人从新编译的, 而且文章还都一样, 什么玩意都是, 自己找到的解决办法记录下

报错信息

OSError: Python library not found: libpython3.7m.so.1.0, libpython3.7mu.so.1.0, libpython3.7.so.1.0
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.

* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)

首先,centos下不需要python3-dev,因为压根没有,那个是Debian/Ubuntu下才有的,所以先不考虑,然后看OSError: Python library not found: libpython3.7m.so.1.0找不到这个,这个是重点,一会要解决。再看这个提示–enable-shared,让我们安装的时候带上这个参数,因为安装python的时候,我没有加,所以,要重装Python,进入到Python文件使用

./configure --prefix=/usr/local/python3 --enable-shared
然后make && make install就好了

现在再次打开python的时候,会报错,
ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory
需要依次执行
echo "/usr/local/python3/lib/" >> /etc/ld.so.conf
ldconfig

Logo

华为云1024程序员节送福利,参与活动赢单人4000元礼包,更有热门技术干货免费学习

更多推荐