pip 安装(win10)
在安装python的时候直接用的zip解压后是没有安装pip包管理工具,需要自己手动安装, 我基本上尝试了网上所有的方法,都没有成功。最终在官方文档中找到答案。
以pip-20.2.4版本为例: pip-20.2.4官方文档
1.下载 get-pip.py 文件
2.命令安装
这里有基本上都是很慢下载如果超时,需要在后面 加上
--timeout 10000
python get-pip.py
python get-pip.py --timeout 10000
3.检验安装是否成功
在python安装文件夹查看是否多了两个文件夹
Lib和Scripts,将Scripts添加到系统环境变量中,查看pip -V是否安装成功,这里会提示没有找到包
4.配置Lib文件到python39._pth
在python安装文件夹中找到
python39._pth文件打开添第一行加Lib\site-packages,再次运行pip -V成功
vs code 安装pylin问题
1.vs code安装pylint问题
pip install -U pylint --user 这里提示distutils.errors.DistutilsPlatformError: User base directory is not specified
2.python -m site
查看 python -m site
sys.path = [
'D:\\DevelopInstalled\\python-3.9.0-embed-amd64\\Lib\\site-packages',
'D:\\DevelopInstalled\\python-3.9.0-embed-amd64\\python39.zip',
'D:\\DevelopInstalled\\python-3.9.0-embed-amd64',
]
USER_BASE: 'C:\\Users\\xxx\\AppData\\Roaming\\Python' (doesn't exist)
USER_SITE: 'C:\\Users\\xxx\\AppData\\Roaming\\Python\\Python39\\site-packages' (doesn't exist)
ENABLE_USER_SITE: None
可以看到doesn't exist,在自己win10用户目录下创建上面USER_BASE和USER_SITE的目录
再次python -m site
sys.path = [
'D:\\DevelopInstalled\\python-3.9.0-embed-amd64\\Lib\\site-packages',
'D:\\DevelopInstalled\\python-3.9.0-embed-amd64\\python39.zip',
'D:\\DevelopInstalled\\python-3.9.0-embed-amd64',
]
USER_BASE: 'C:\\Users\\xxx\\AppData\\Roaming\\Python' (exists)
USER_SITE: 'C:\\Users\\xxx\\AppData\\Roaming\\Python\\Python39\\site-packages' (exists)
ENABLE_USER_SITE: None
再次执行 pip install -U pylint --user 还是提示distutils.errors.DistutilsPlatformError: User base directory is not specified
3.配置python39._pth,修改ENABLE_USER_SITE
Lib\site-packages
python39.zip
.
# Uncomment to run site.main() automatically
import site
ENABLE_USER_SITE = False