我在docker容器中运行py 2.7.18,在centos 7中使用rh-python27包。
我的一个项目需要 gitdb
包,当我运行docker容器时,它抱怨没有找到gitdb。但我在req.txt中提到了这一点。
我在docker容器中进行故障排除,发现以下行为。有人能给我解释一下这种行为的原因吗。为什么? python
指的是 opt/rh/python27....
而不是 /usr/bin/python
?
root@cicd-docker CENTOS7 /usr/bin > pwd
/usr/bin
root@cicd-docker CENTOS7 /usr/bin > ./python
Python 2.7.18 (default, Oct 23 2020, 13:34:23)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.__file__
'/usr/lib64/python2.7/os.pyc'
>>> import gitdb
>>> exit()
root@cicd-docker CENTOS7 /usr/bin > python
Python 2.7.18 (default, Oct 23 2020, 13:34:23)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.__file__
'/opt/rh/python27/root/usr/lib64/python2.7/os.pyc'
>>> import gitdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gitdb
>>> exit()
root@cicd-docker CENTOS7 /usr/bin > sudo python
Python 2.7.5 (default, Nov 16 2020, 22:23:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.__file__
'/usr/lib64/python2.7/os.pyc'
>>> import gitdb
>>> exit()
root@cicd-docker CENTOS7 /usr/bin >
或者,在centos docker中安装python2.7.18的正确方法是什么。
提前谢谢。
暂无答案!
目前还没有任何答案,快来回答吧!