ubuntu18.04不能安装python2.7(依赖冲突),网上搜索了很多解决办法,并不好使。
直接使用docker pull
一个新的ubuntu
系统镜像并运行,配置环境
sudo docker pull paopaorobot/ubuntu-xfce-vnc:16.04
sudo docker run -it -p 5900:5900 -v [你想映射的目录]:/root/data paopaorobot/ubuntu-xfce-vnc:16.04
在vnc viewer
中链接5900,打开终端,cd
到你映射的目录如/root/data
,如下
在终端运行python2 associate.py rgb.txt depth.txt >> assoc.txt
报错,提示
root@ecf60995ac42:~/data# python2 associate.py rgb.txt depth.txt >> assoc.txt
Traceback (most recent call last):
File "associate.py", line 46, in <module>
import numpy
ImportError: No module named numpy
从仓库安装pip
[不好使,建议手动安装]
apt-get update
apt install python-pip
使用pip
安装,提示错误
root@ecf60995ac42:~/data# pip install numpy
Collecting numpy
Downloading https://files.pythonhosted.org/packages/3a/be/650f9c091ef71cb01d735775d554e068752d3ff63d7943b26316dc401749/numpy-1.21.2.zip (10.3MB)
100% |################################| 10.3MB 153kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-4bFKU6/numpy/setup.py", line 27, in <module>
import builtins
ImportError: No module named builtins
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-4bFKU6/numpy/
You are using pip version 8.1.1, however version 21.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pip install --upgrade pip
也失败了
root@ecf60995ac42:~/data# pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/52/e1/06c018197d8151383f66ebf6979d951995cf495629fc54149491f5d157d0/pip-21.2.4.tar.gz (1.6MB)
100% |################################| 1.6MB 882kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-eSROaQ/pip/setup.py", line 7
def read(rel_path: str) -> str:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-eSROaQ/pip/
You are using pip version 8.1.1, however version 21.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
最后只能手动安装pip
在官网下载get-pip.py
文件,放置在sudo docker run -it -p 5900:5900 -v [你想映射的目录]:/root/data paopaorobot/ubuntu-xfce-vnc:16.04
中你想映射的目录下(会自动同步到/root/data
文件夹下),然后在上述vnc viewer
中打开的终端中继续输入
python get-pip.py
如下安装成功
root@ecf60995ac42:~/data# python get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip<21.0
Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
|################################| 1.5 MB 1.2 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 8.1.1
Uninstalling pip-8.1.1:
Successfully uninstalled pip-8.1.1
Successfully installed pip-20.3.4
在vnc viewer
中重新打开一个终端(很重要,旧的终端文件系统未更新,会提示错误),然后运行
root@ecf60995ac42:~/data# pip install numpy
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting numpy
Downloading numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl (17.0 MB)
|################################| 17.0 MB 288 kB/s
Installing collected packages: numpy
Successfully installed numpy-1.16.6
最终成功
root@ecf60995ac42:~/data# python2 associate.py rgb.txt depth.txt >> assoc.txt
root@ecf60995ac42:~/data#