安装python库报错:Consider using the `--user` option or check the permissions.

昨天在服务器上训练ResNet,导包出现了一些小问题:
1)安装tqdm库的时候,出现 Consider using the ‘–user’ option or check the permissions.访问python下的site-package权限不够。添加‘–user’即可,再次尝试使用以下命令

pip3 install --user --upgrade tqdm -i https://pypi.tuna.tsinghua.edu.cn/simple

问题解决。
2)使用torch和torchvision的时候出现异常,Invoked with: typing.Union[int, NoneType], None, <function try_ann_to_type.
解决方案:降低torch和torchvision的版本,我原来的版本是torch1.5.1 torchvision0.6.1,之后我使用以下命令:

pip3 uninstall torch
pip3 uninstall torchvision

完成卸载,之后又使用以下命令重新安装了低版本的torch和torchvision

pip3 install torch==1.4.0 torchvision==0.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

附:

1、国内使用Pytorch官方网站下载pip库很慢,推荐使用清华源。清华源的链接:
https://pypi.tuna.tsinghua.edu.cn/simple
2、使用pip从清华源安装python库的时候,可以使用以下命令(python2需要将pip3换为pip,加载其他库的时候,直接把torchvision换成需要的库即可,还可以指定版本噢):

pip3 install torchvision==0.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

3、加载torch和torchvision的时候要注意它们之间的版本要匹配,以下是它们的版本匹配表(Pytorch官方):https://pypi.org/project/torchvision/

猜你喜欢

转载自blog.csdn.net/Dartao/article/details/124074141