Python(相关问题总结)

1. 解决pip下载超时问题
我们在用默认的pip源进行安装python库时,会出现超时问题,导致下载失败。

解决方法:
我们可以选择国内的镜像来解决问题,- i 后面为国内镜像地址。
例:安装numpy库时,直接在终端输入命令,
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
几种常用的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/


2. python成功安装torch模块
torch直接使用pip install 安装一直安装不成功。

解决办法:
环境是python 3.8, 使用pip命令:
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
注:=和+d的前后之间不能有空格


3. 关于pip安装第三方库,但PyCharm确无法识别的问题
在cmd控制台 pip install *** 显示安装成功, 并且用cmd的python 中的 import ***, 没有显示异常,说明库是安装成功的。但是在PyCharm中导入库时确出现问题, 显示:没有这个模块。

解决办法:
https://blog.csdn.net/weixin_41287260/article/details/83957731#%E4%B8%80%E3%80%81%E9%97%AE%E9%A2%98%E5%85%B7%E4%BD%93%E6%8F%8F%E8%BF%B0%EF%BC%9A


4. 关于anaconda:
https://blog.csdn.net/sinat_26917383/article/details/52933407?locationNum=7&fps=1


5.pygame中检测两个物体碰撞的函数:
1.两个单个物体(精灵)的碰撞
pygame.sprite.collide_rect(balls, basket)
2.精灵和组之间的碰撞
pygame.sprite.spritecollideany(ship, aliens)
3.组与组之间的碰撞
pygame.sprite.groupcollide(bullets, aliens, True, True)

6.pygame报错 Environment location directory is not empty:
https://www.cnblogs.com/HoD7/p/12128265.html

你可能感兴趣的:(Python(相关问题总结))