一、pip安装失败
1、手动换源
运行如下命令:
pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com packName
packName
为要安装的包
2、永久换源
在C:\Users\xxx
路径下,创建pip
文件夹,进入后创建pip.ini
文件并写入以下内容,这样会挨个在以下源里寻找,找到了就下载,找不到就失败。
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
extra-index-url =
https://mirrors.aliyun.com/pypi/simple/
https://pypi.douban.com/simple/
https://pypi.mirrors.ustc.edu.cn/simple/
https://pypi.org/simple/
https://pypi.python.org/simple/
[install]
trusted-host =
pypi.tuna.tsinghua.edu.cn
mirrors.aliyun.com
pypi.douban.com
pypi.mirrors.ustc.edu.cn
pypi.org
pypi.python.org
*常用源:
//阿里云
https://mirrors.aliyun.com/pypi/simple/
//百度:
https://mirror.baidu.com/pypi/simple/
//中国科技大学
https://pypi.mirrors.ustc.edu.cn/simple/
//豆瓣(douban)
https://pypi.douban.com/simple/
//清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
//中国科学技术大学
https://pypi.mirrors.ustc.edu.cn/simple/
//搜狐:
http://mirrors.sohu.com/Python/
//官方源
https://pypi.python.org/simple
https://pypi.org/simple
(我也不知道为什么有两个。。)
二、手动安装github下载的py包
解压后进入文件夹,找到setup.py
文件所在位置,在文件夹中按住shift+右键
打开cmd,运行如下命令:
python setup.py install
三、python包所在位置
C:\Users\xxx\Anaconda3\Lib
四、无法import自己写的py文件
- 在所引用的py文件所在文件夹下创建一个新的
__init__.py
文件,空的就行。(貌似有时候不行。。) - 设置当前
project
的根目录为Sources Root
,如图所示:
五、手动配置某些pip搞不定的环境
搜索并下载相应的whl
文件,下载完成后在pycharm的控制台里pip install xxx.whl
- 例:
pip install torch-1.12.1+cu116-cp37-cp37m-win_amd64.whl
六、Tensorboard打开方式
Terminal
里输入tensorboard --logdir="./xxx/xxx"
,然后点击网址即可,例如:
七、Linux下载太慢且容易中断
常规用法wget+url
,下载太慢且容易中断。
改用其他下载方式,如aria2c,支持多线程下载。
sudo apt-get update
sudo apt-get install aria2
基本用法(多线程):
aria2c -x 16 [URL]
# 16代表16个线程
不定时更新ing…