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

conda 创建FastAPI运行环境

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

conda 创建FastAPI运行环境

目录

conda创建环境

创建环境

激活环境

conda的其他命令

设置下载源

清华源

中科大源

conda恢复默认源

pip临时源

pip设置源

其他源

安装FastAPI

参考:


conda创建环境

创建环境
conda create --name yourEnv python=3.9
#或者 
conda create -n yourEnv python=3.9

截至目前Python3.10也出来了 (2021.10.04)

  • --name:也可以缩写为 【-n】,【yourEnv】是新创建的虚拟环境的名字,创建完,可以装anaconda的目录下找到envs/yourEnv 目录(参考文献写的-name,实际运行会出现错误)
  • python=3.9:是python的版本号。也可以指定为【python=3.10】,若未指定,默认为是装anaconda时python的版本.

# -name 会出现报错
conda create -name py3 python=3.9

Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - py3

若想要在创建环境同时安装python的一些包:
conda create -n yourEnv python=3.9 numpy pandas

若想在别人虚拟环境的基础上创建自己的环境:
conda create --name --clone

激活环境

activate yourEnv

conda的其他命令

conda info --envs:输出中带有【*】号的的就是当前所处的环境

conda list: 看这个环境下安装的包和版本

conda install numpy scikit-learn: 安装numpy sklearn包

conda env remove -n yourEnv: 删除你的环境

conda env list: 查看所有的环境

设置下载源

有时候下载比较慢 需要国内下载

清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --set show_channel_urls yes

中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes

conda恢复默认源
conda config --remove-key channels

pip临时源

pip install 模块名 -i https://pypi.org/simple

#举例
pip install uvicorn -i https://pypi.tuna.tsinghua.edu.cn/simple/

pip设置源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

其他源

豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn

安装FastAPI

使用 FastAPI 需要 Python 版本大于等于 3.6

首先是 pip install fastapi,会自动安装 Starlette 和 Pydantic;

然后还要 pip install uvicorn,因为 uvicorn 是运行相关应用程序的服务器。

或者一步到位:pip install fastapi[all],会将所有依赖全部安装

参考:

conda创建新环境_SARACH_WONG的博客-CSDN博客_conda 创建新环境

Anaconda更换清华源、中科大源_OuDiShenmiss的博客-CSDN博客_anaconda 中科大源

FastAPI:Python 世界里最受欢迎的异步框架 - 古明地盆 - 博客园

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

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

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