修改pip第三方包安装位置
修改Python安装路径下的site.py文件;如C:\Program Files(x86)\Python38\Lib\site.py
把USER_SITE和USER_BASE修改为你想要的位置,USER_SITE是实际安装包的位置。
(如果保存时提示“拒绝访问”,则先给site.py文件配写入和修改权限)
# 修改前:
USER_SITE = None
USER_BASE = None
# 修改后:
USER_SITE = "E:/python/python37/Lib/site-packages" # 原值None
USER_BASE = "E:/python" # 原值None
在 user/(用户名)/ 目录下新建 pip 文件夹,里面新建 pip.ini 文件,写入:
[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/
target=D:/Python/Python38/site-packages
(这里顺便给pip换了阿里云源)
最后用cmd看看:
python -m site
镜像源配置
在 user/(用户名)/ 目录下新建 pip 文件夹,里面新建 pip.ini 文件,写入:
[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/
在文件夹右键打开CMD
打开
HKEY_CLASSES_ROOT\Directory\Background\shell
点击shell>右键>新建项,新建项的名字就是右键菜单里将显示的名字,比如“open CMD here”;
然后在你自己起的这个名字上右键>新建>项,起名必须叫做 command;
点到你写的 command 上到右边,在这个默认上双击,写上 cmd.exe。
新建虚拟环境
输入盘符
C:\Users\(用户名)>f:
cd到虚拟环境scripts目录
F:\>cd F:\storage\Machine_Learning\DLenv\Scripts
激活虚拟环境
F:\storage\Machine_Learning\DLenv\Scripts>activate
(DLenv) F:\storage\Machine_Learning\DLenv\Scripts>
退出虚拟环境
(DLenv) F:\storage\Machine_Learning\DLenv\Scripts>deactivate
遇到警告提示pip版本过低,先尝试升级pip的指令下载最新的包
然后,venv-script下 easy_install pip,就可以将pip自动升级到最高
easy_install pip
pip常用指令
# 查看pip已安装列表
pip list
pip install [...]
pip3 install --upgrade pip
python -m ensurepip
# 更新pip
python -m pip install --upgrade pip
python -m pip install --user --upgrade pip
# 卸载安装的包
pip uninstall[...]
# 产看python版本
python --version
pyhon -V
# 卸载所有包的方法
pip freeze > allpackages.txt
pip uninstall -r allpackages.txt -y
# 安装sklearn的步骤
python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
python -m pip install numpy scipy matplotlib ipython jupyter pandas sympy nose
pip install -U scikit-learn
CMD指令
# 显示目录下文件
dir
jupyter
jupyter无token修改josn
"NotebookApp": {
"password": "argon2:$argon2id$v=19$m=10240,t=10,p=8$JFEFxJSpvu9xnRp94aScBA$oWQ1ObKh0csAsYS9Tgvrmw"
}
已删除
替换配置文件
jupyter notebook --generate-config 将这个路径下的配置文件替换为默认配置文件
Writing default config to: C:\Users\Administrator\.jupyter\jupyter_notebook_config.py