系统:Ubuntu 20.04 LTS
背景:系统仅预装python 3.8,以下将自行安装python 2.7。
1. 安装python2.7
- 下载python2.7 源文件,解压,进入目录;
./configure --enable-unicode=ucs4make -jsudo make install
文件: https://www.python.org/downloads/release/python-2718/
参考:https://eli.thegreenplace.net/2011/10/10/installing-python-2-7-on-ubuntu
https://passingcuriosity.com/2015/installing-python-from-source/
2. 安装setuptools
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python2.
3. 安装pip
- 下载pip源文件,解压,进入目录;
sudo python2 setup.py install
这一步依赖setuptools.
文件: https://pypi.org/project/pip/#files
验证
python2 -V: Python 2.7.18
pip2 -V: pip 20.1.1 from /usr/local/lib/python2.7/site-packages/pip-20.1.1-py2.7.egg/pip (python 2.7)
来填坑了
tensorflow 出错
- 安装tensorflow 1.3.0 (tensorflow-1.3.0-cp27-cp27mu-manylinux1_x86_64.whl)出错,错误信息"… is not a supported wheel on this platform.“;
- 改装tensorflow(tensorflow-1.3.0-cp27-none-linux_x86_64.whl)成功,但是
import tensorflow as tf出错,错误信息“ImportError: /usr/local/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyUnicodeUCS4_FromString"。
解决办法: 编译python时, ./configure 改成./configure --enable-unicode=ucs4
详见: http://www.cppblog.com/wicbnu/archive/2018/09/13/215928.html
新的解决方案
下载安装conda, conda创建虚拟环境, 在虚拟环境安装python2.7.(不会搞乱系统环境,代价是不同虚拟环境不能公用包所以会多占用一部分存储空间)
在Ubuntu 20.04 LTS上手动安装Python 2.7,包括下载源文件、安装setuptools和pip。在安装TensorFlow 1.3.0时遇到平台不支持和导入错误的问题,通过修改Python编译选项和使用conda虚拟环境解决了问题。
1519

被折叠的 条评论
为什么被折叠?



