栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

pycharm新建flask项目时报错:install flask failed

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pycharm新建flask项目时报错:install flask failed

背景:
昨天在新建flask项目时出现了以下报错提示:
ERROR: Could not find a version that satisfies the requirement flask (from versions: none),几经搜索,解决了,在此做个小结。

解决方案:
若出现erro:install flask failed,或者因请求超时问题而无法安装成功时,
可尝试在终端使用命令:pip install flask -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com 进行安装

即使用国内一些镜像源安装(上述就是使用豆瓣镜像源下载的),
格式是pip install 包名 -i 指定镜像源地址(记得带上/simple/),后面那一串是根据进一步报错信息添加滴

关于这个问题如果想设置pip安装时默认使用某镜像源的话:
Windows下,可通过在本地C:userxxpip(若没有pip文件夹需自己新建)内新建pip.ini,并在其内写入以下内容:
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
这样,在使用pip时就会调用该镜像进行安装。

Linux/Mac os 环境中,配置文件位置在 ~/.pip/pip.conf(如果不存在创建该目录和文件):
mkdir ~/.pip
打开配置文件 ~/.pip/pip.conf,修改如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
查看 镜像地址:
$ pip3 config list
global.index-url=‘https://pypi.tuna.tsinghua.edu.cn/simple’
install.trusted-host=‘https://pypi.tuna.tsinghua.edu.cn’
可以看到已经成功修改了镜像。

另附其他国内pip源地址:

豆瓣 http://pypi.douban.com/simple/

阿里云 http://mirrors.aliyun.com/pypi/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

(上述镜像源地址纯属按长短进行排名,别无它意,嘻嘻)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/460946.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号