linux pip 软链接,Ubuntu python 软链接或调用pip有问题

在使用ubuntu时有时会用到docker比如tensorflow跟PyTorch的官方镜像。但有时会遇到无法直接调用python,或者调用pip有问题,这是因为 docker 镜像默认没有把 python 软链接。

这时我们需要whereis python

把本机上所有的 python 列举出来。

例如 pytorch/pytorch:1.7.0-cuda11.0-cudnn8-devel 显示是

root@6d0dd29bd661:# whereis python python:/opt/conda/bin/python3.8/opt/conda/bin/python /opt/conda/bin/python3.8-config

那么python的路径就是在 /opt/conda/bin/python3.8 这里,接下来我们只需要IS

/opt/conda/bin/python3.8

即可。

显示例子:

e4ecad96c91e

root@6d0dd29bd661:#Is

root@6dedd29bd661:#/opt/conda/bin/python3.8

Python 3.8.3(default, May 19 2020,18:47:26)

[ GCC 7.3.0]:: Anaconda, Inc. on linux Type "help","copyright","credits"or "license"for more information.

>>>import torch

然后软连接的方式是:echo "export PATH=\"/opt/conda/bin:\$PATH\"">>/root/.bashrc && source /root/.bashrc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值