我正在尝试在openSUSE 42.2上从源代码安装新的Python(3.6,仅在几周前发布)。一切

./configure --prefix /home/paul/2017 --enable-optimizations
make
make install


看起来工作正常,但是当我调用闪亮的新解释器时,出现以下错误:

Python 3.6.0 (default, Jan  9 2017, 22:01:27)
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "/home/paul/.pythonrc", line 7, in <module>
    import readline
ModuleNotFoundError: No module named 'readline'


现在,该模块在那里,它已安装在$ PREFIX / lib64 / python3.6 / lib-dynload / readline.cpython-36m-x86_64-linux-gnu.so下。
只有解释器不在那儿(它完全忽略了lib64,我用-vv检查过)。

更新:显然,这不仅会影响readline,还会影响lib64下的所有内容,尤其是lib-dynload下的模块。

这似乎是一个已知问题,请参见the Python bugtracker。这是一个相当漫长的交流,结尾为


  在这里需要做什么达成共识吗?我想在它达到10岁生日之前将其变成3.5 :)


这让我有些困惑。这个应该解决吗?
我不记得曾经遇到过这个问题,所以我想知道这是否是3.6回归。

显然,任何修复都将受到欢迎。

更新:目前,我可以通过将lib64下的所有内容符号链接到lib中来解决此问题。显然,这不是理想的解决方案。至少,它首先达到了引入lib64(能够并排拥有32和64位版本)的目的。
我非常喜欢配置文件中的内容。

最佳答案

opensuse devel:languages:python:Factory python3 package为此提供了补丁。
规格文件通常是一个很好的起点。

注意:install步骤将在python3中安装/usr/local/bin。将其更改为altinstall可以避免覆盖系统范围的python3

安装

创建一个downloads变量,该变量指向将保存所有下载文件(python sourcefactory patches)的目录

export downloads=/usr/local/build/downloads


在用户可写目录中:

tar --no-same-owner -xvf $downloads/Python-3.6.4.tar.xz
cd Python-3.6.4

patch -p1 < $downloads/python-3.6.0-multilib-new.patch
patch -p0  < $downloads/python-3.3.0b1-localpath.patch
patch -p0 < $downloads/python-3.3.0b1-curses-panel.patch

# mind this step, otherwise
# none of the modules in `lib-dynload` could be imported !
autoreconf -i

mkdir build; cd $_
../configure --enable-optimizations --enable-ipv6 \
             --with-fpectl --enable-shared --with-system-ffi \
             --with-system-expat --enable-loadable-sqlite-extensions
make -j $(nproc)
# altinstall, not install (see above)
sudo make altinstall


卸载

摆脱已安装的文件:

sudo rm -rf /usr/local/lib64/python3.6/
sudo rm -f /usr/local/lib64/libpython3.6m*
sudo rm -f /usr/local/lib64/libpython3.so
sudo rm -f /usr/local/lib64/pkgconfig/python-3.6*
sudo rm -f /usr/local/bin/python-3.6*


对于python3.7

tar --no-same-owner -xvf $downloads/Python-3.7.3.tar.xz
cd Python-3.7.3
patch -p1 < $downloads/python-3.7.3-python-3.6.0-multilib.patch
patch -p1 < $downloads/python-3.7.3-distutils-reproducible-compile.patch
patch -p0 < $downloads/python-3.7.3-python-3.3.0b1-localpath.patch
patch -p0 < $downloads/python-3.7.3-00251-change-user-install-location.patch

# do not forget !
autoreconf -i

mkdir build; cd $_
../configure --enable-optimizations --enable-ipv6 --enable-shared --with-system-ffi --with-system-expat --enable-loadable-sqlite-extensions

make -j $(nproc)

sudo make altinstall


对于python 3.8

tar --no-same-owner -xvf $downloads/Python-3.8.1.tar.xz
cd Python-3.8.1/
patch -p1 < $downloads/python-3.8.1-F00102-lib64.patch
patch -p1 < $downloads/python-3.8.1-F00251-change-user-install-location.patch
patch -p1 < $downloads/python-3.8.1-SUSE-FEDORA-multilib.patch
patch -p1 < $downloads/python-3.8.1-distutils-reproducible-compile.patch
patch -p1 < $downloads/python-3.8.1-python-3.3.0b1-localpath.patch

# do not forget !
autoreconf -i

mkdir build; cd $_
../configure --enable-optimizations --enable-ipv6 --enable-shared \
             --with-system-ffi --with-system-expat \
             --enable-loadable-sqlite-extensions
make -j $(nproc)
# altinstall, not install (see above)
sudo make altinstall

关于python - python 3.6安装和lib64,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41558535/

10-11 14:23