armUbuntu | armv7l ubuntu | 安装完python之后,没有pip

王先生
2023-10-30 / 0 评论 / 22 阅读 / 正在检测是否收录...

检查环境信息:

root@xx:/# python -V
Python 3.5.2
root@xx:/# ls /usr/local/lib/python3.5/dist-packages/
root@xx:/# cd /usr/local/lib/python3.5/dist-packages/
root@xx:/usr/local/lib/python3.5/dist-packages# ls

root@xx:/usr/local/lib/python3.5/dist-packages# whereis python
python: /usr/bin/python /usr/bin/python3.5m /usr/bin/python3.5 /usr/lib/python3.5 /usr/lib/python2.7 /etc/python3.5 /usr/local/lib/python3.5
root@xx:/usr/local/lib/python3.5/dist-packages# uname -a
Linux xx 4.1.15 #1 SMP PREEMPT Fri Dec 18 13:01:09 CST 2020 armv7l armv7l armv7l GNU/Linux

/usr/bin/python 软连 的是 python3.5
目标: 给python3.5装上pip

检查 cd /usr/local/lib/python3.5/dist-packages/ 文件夹下发现没有pip文件夹,也就是没装python3.5的pip

开始安装:

由于我是nfs在线挂载的根文件系统,不知为何无法使用dns服务,所以在hosts中修改了需要用到域名的相关信息

vim /etc/hosts
127.0.0.1 localhost
127.0.0.1 LJW_RY_V1.0.0
# 185.125.190.39 ports.ubuntu.com
# 101.6.15.130 mirrors.tuna.tsinghua.edu.cn
# 146.75.112.175 bootstrap.pypa.io
# 123.6.21.222 mirrors.aliyun.com

将上述代码中的注释取消掉,为了保证服务的通畅性,在下载到板子之前需要注释掉或者删掉

获取安装文件

运行下述命令,得到安装文件

wget http://bootstrap.pypa.io/pip/3.5/get-pip.py
如果无法解析域名,请检查/etc/systemd/resolved.conf中是否有DNS=,没有的话添加"DNS=223.5.5.5"
NFS挂载文件系统下无法使用,请注意
nfs 挂载根文件系统的情况下,目前我找到的方法为,用PC机ping域名,找到ip,然后在板子上的/etc/hosts中添加进去,之后就可以用了

执行安装文件

使用国内源安装 pip :

python get-pip.py -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
NFS挂载根文件系统的情况下,dns服务貌似无法正常工作
nfs 挂载根文件系统的情况下,目前我找到的方法为,用PC机ping域名,找到ip,然后在板子上的/etc/hosts中添加进去,之后就可以用了。
如果各位有更好的方法欢迎评论留言

pip国内的一些镜像

  阿里云 http://mirrors.aliyun.com/pypi/simple/
  中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
  豆瓣(douban) http://pypi.douban.com/simple/
  清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
  中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

修改源方法:

临时使用:

可以在使用pip的时候在后面加上-i参数,指定pip源
eg: pip install scrapy -i http://mirrors.aliyun.com/pypi/simple/

永久修改:

linux:

修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

windows:

直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,在pip 目录下新建文件pip.ini,内容如下

或者按照网友的建议:win+R 打开用户目录%HOMEPATH%,在此目录下创建 pip 文件夹,在 pip 目录下创建 pip.ini 文件, 内容如下

[global]
timeout = 6000
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

评论 (0)

取消