flask怎么创建虚拟环境

编程 系统 (Programming, Systems)

什么是虚拟环境? (What is a Virtual Environment?)

A virtual environment creates separate space for a project with its dependencies at a definite place. This environment is distinct to the specific project and doesn’t interfere with other project dependencies.

虚拟环境为项目创建了单独的空间,并在一定位置上具有依赖项。 此环境与特定项目不同,并且不会干扰其他项目依赖项。

虚拟环境的优势? (Advantages of Virtual Environment?)

A virtual environment creates it’s own dependencies and space instead of disturbing the local environment.

虚拟环境会创建自己的依赖关系和空间,而不会干扰本地环境。

After activating the virtual environment, it provides the facility to freeze the current state of the environment packages.

激活虚拟环境后,它提供了冻结环境软件包当前状态的工具。

Virtual Environment provides a facility to install any packages as well as notebooks.

虚拟环境提供了一种安装所有软件包和笔记本的功能。

动机 (Motivation)

Everybody might come across this term called Virtual Environment. For the people who work with multiple projects in the localhost. Due to the requirements of each project, there is more chance of jumbling all packages in the same localhost. This leads to the improper organization of all the packages and mixing up of all packages. This is a time-consuming process to debug the projects.

每个人都可能遇到称为虚拟环境的术语。 对于在本地主机中处理多个项目的人员。 由于每个项目的要求,更有可能在同一个本地主机中装满所有软件包。 这导致所有包装的不正确组织和所有包装的混合。 这是调试项目的耗时过程。

If you want to check and run the other’s project in your localhost. You need to install dependencies and packages related to the corresponding project. So, While working with multiple projects. It is better to create Virtual Environments instead of disturbing local environments and dependencies.

如果要在本地主机中检查并运行其他人的项目。 您需要安装与相应项目相关的依赖项和软件包。 因此,在处理多个项目时。 最好创建虚拟环境,而不要打扰本地环境和依赖项。

In simple words, Let me give you an example :

简单来说,让我举一个例子:

So, You have created a flask app which is an interface of the Machine Learning model and website. You used scikit_learn package version 0.21.3 to create pickle files. Your friend asked you to check his/her project which is having the pickle files containing scikit_learn package version 0.23.1. To help your friend, you have installed all the requirements of that project and you helped your friend. But, The first project won’t work. Because you have installed some other versions of packages. So you need some time to re-install your packages and make your first project work. Instead of facing these types of issues, it’s better to create virtual environments while working with multiple projects.

因此,您创建了一个flask应用程序,它是机器学习模型和网站的接口。 您使用scikit_learn软件包0.21.3版创建了pickle文件。 您的朋友要求您检查他/她的项目,该项目的泡菜文件包含scikit_learn软件包版本0.23.1。 为了帮助您的朋友,您已经安装了该项目的所有要求,并帮助了您的朋友。 但是,第一个项目将无法正常工作。 因为您已经安装了其他版本的软件包。 因此,您需要一些时间来重新安装软件包并开始第一个项目的工作。 最好不要在处理多个项目时创建虚拟环境,而要面对这些类型的问题。

入门 (Getting Started)

This article guides you to create a virtual environment and run your flask application in your localhost containing the Windows Operating system by using various methods:

本文指导您使用各种方法创建虚拟环境并在包含Windows操作系统的本地主机中运行flask应用程序:

Command prompt

命令提示符

Anaconda prompt

Anaconda提示

Ubuntu application

Ubuntu应用程序

使用命令提示符创建虚拟环境 (Create virtual Environment using Command prompt)

  1. Installation of Python and pip :安装Python和pip:

Open the command prompt. Check your laptop is having Python as well as pip or not. Use the below commands to check them. you should write two hyphens as in the image. The latest version of python contains pip pre_installed only for older versions you need to install manually.

打开命令提示符。 检查您的笔记本电脑是否具有Python和pip。 使用以下命令进行检查。 您应该像图片中那样写两个连字符 。 最新版本的python包含pip pre_installed仅适用于您需要手动安装的旧版本。

python — version

python —版本

pip — version

点-版本

If you don’t have python in your computer download it here and add the path to the environment variables. If you don’t have pip installed in your computer download it here to a folder on your computer and save it with the same name “get-pip.py”. Open a command prompt and navigate to the folder containing the get-pip.py installer.

如果您的计算机中没有python,请在此处下载 python,然后将路径添加到环境变量中。 如果您的计算机中未安装pip,请在此处将其下载到计算机上的文件夹中,并使用相同的名称“ get-pip.py”进行保存 。 打开命令提示符,然后导航到包含get-pip.py安装程序的文件夹。

Run the following command:

运行以下命令:

python get-pip.py

python get-pip.py

2. Navigate to the directory contains the Flask application.

2.导航到包含Flask应用程序的目录。

Make sure that your flask folder containing all the files required to run on your laptop.

确保您的flask文件夹包含在笔记本电脑上运行所需的所有文件。

Use these commands to navigate the command prompt:

使用以下命令导航命令提示符:

To navigate one step back from the current path use:

要从当前路径向后退一步,请使用:

cd..

光盘..

To move into the folder from the current path use:

要从当前路径移入文件夹,请使用:

cd<space>[specified_folder]

cd <空格> [specified_folder]

This is the path of my flask app on my laptop.

这是我的烧瓶应用程序在笔记本电脑上的路径。

Using the above commands and navigate to the flask app folder.

使用以上命令并导航至flask应用程序文件夹。

( or )

( 要么 )

2. Clone the directory from GitHub.

2.从GitHub克隆目录。

If you don’t have Git installed in your Computer download it here. Clone the repository by using the following commands. On running the first command a folder is created(clone) in your specified path.

如果您的计算机中未安装Git,请在此处下载 。 使用以下命令克隆存储库。 在运行第一个命令时,将在您指定的路径中创建一个文件夹(克隆)。

git clone [link_of_repository]

git clone [link_of_repository]

cd [repository_name]

cd [repository_name]

3. Check the list of files in your flask app folder by using the following command:

3.使用以下命令检查flask应用程序文件夹中的文件列表:

dir

目录

4. Install Virtual environment in your folder by using the following command:

4.使用以下命令在您的文件夹中安装虚拟环境:

pip install virtualenv

pip安装virtualenv

5. Name your virtual environment by using the following command:

5.使用以下命令命名您的虚拟环境:

virtualenv [virtual_environment_name]

virtualenv [virtual_environment_name]

6. Navigate to your virtual environment folder and there you will see scripts folder.

6.导航到您的虚拟环境文件夹,您将在其中看到脚本文件夹。

That is the folder which contains all operations of Virtual environment and “activate” your venv by using the command:

该文件夹包含虚拟环境的所有操作,并使用以下命令“ 激活 ”您的虚拟电话:

activate

启用

You will see a name on the left side of the terminal in brackets. By this, A virtual environment is activated.

您将在终端的左侧方括号中看到一个名称。 由此,激活了虚拟环境。

您的工作完成了... !!!

flask怎么创建虚拟环境_在Windows OS中创建虚拟环境并在本地运行Flask应用程序相关推荐

  1. uac管理员程序_在Windows 10中创建没有UAC提示的管理员模式快捷方式

    uac管理员程序 User Access Control (UAC) prompts in Windows 10 can be annoying, especially when you often ...

  2. vue 递归创建菜单_如何在Vue中创建类似中等的突出显示菜单

    vue 递归创建菜单 by Taha Shashtari 由Taha Shashtari 如何在Vue中创建类似中等的突出显示菜单 (How to Create a Medium-Like Highl ...

  3. 如何在mysql中创建过程_如何在MySQL 中创建存储过程?

    问题阐述 自MySQL 5.0 开始,MySQL 就支持存储过程.存储过程是一些被用户定义的SQL 语句集合.一个存储程序是可以被存储在服务器中的一套SQL 语句.存储过程可以被程序.触发器或另一个存 ...

  4. vue在日历表上面创建事件_如何在R中创建颜色编码的日历

    vue在日历表上面创建事件 用颜色编码的日历可以快速简便地查看您是否实现了日常目标. 您是否符合销售或社交媒体帖子等日常业务指标? 或者,您如何实现个人目标,例如每天锻炼? 乍一看,您可以了解自己的工 ...

  5. 如何在mysql中创建连接_如何在MySQL中创建新用户并开启远程连接访问?

    如何在MySQL中创建新用户并开启远程连接访问? 发布时间:2020-05-21 14:55:19 来源:亿速云 阅读:176 作者:鸽子 下面由mysql教程给大家介绍MySQL创建新用户并开启远程 ...

  6. python中如何创建包_如何在Python中创建命名空间包?

    TL:博士: 在Python3.3上,您不必做任何事情,只要不在名称空间包目录中放置任何__init__.py,它就可以工作了.在pre-3.3中,选择pkgutil.extend_path()解决方 ...

  7. python中怎么创建配置文件_如何在Django中创建配置文件注册表单?

    我试图创建一个定制的注册表单,但是我不知道如何去做,因为我试图将默认的django注册与一个新的模型连接起来.在 这是它看起来的样子,可能是错的,但我正在考虑这样的事情.在 模型.pyclass Pr ...

  8. python动态创建字典_如何在Python中创建动态命名字典?

    与其尝试动态生成一个动态数量的变量名,不如选择另一个更高级别的数据结构来存储对象,例如字典或列表.在import pandas as pd REFERENCE_CODE = ["ladder ...

  9. python怎么创建函数_如何在python中创建自己的map()函数

    调用函数时,请使用星号*: def mapper(func, *sequences): result = [] if len(sequences) > 0: minl = min(len(sub ...

  10. BC30138: 无法在路径“C:\WINDOWS\TEMP\”中创建临时文件: 拒绝访问。

    今天一客户打电话说页面无法加载,我过去看了下出现下面的问题.这样的问题也是程序在运行时常遇见的,所以在解决后就给贴出来了~~ 问题:BC30138: 无法在路径"C:\WINDOWS\TEM ...

最新文章

  1. linux系统中指定端口连接数限制
  2. 【Netty】ByteBuf--Netty的数据容器
  3. jQuery对表单、表格的操作以及更多应用
  4. 第三日:继续恢复网站
  5. 手写Python中列表和字符串的反转
  6. StackOverflow How to programmatically unplug replug an arbitrary USB device? 如何以编程方式拔出并重新插入任意USB设备
  7. 210314阶段三VS使用Linux 的sqlite3 API
  8. 前端面试分享:秋招总结(html和css篇)
  9. git 发布android 系统版本 修改版本型号 查看指定文件的修改记录
  10. C++ 虚拟继承与虚基类
  11. 数据交互什么意思_学习编程怎么样才可以不枯燥?什么是前端语言?
  12. linux docker端口映射无法访问,docker设置了端口映射,不能访问的解决方案
  13. 再读华为代码规范文档
  14. 规范规约是最左规约吗_Java开发者必须要知道的MySQL规范
  15. java semaphore 原理_Java并发编程原理与实战二十八:信号量Semaphore
  16. coolfire文章之二
  17. 小程序保存图片相册无响应
  18. 计算机网络(二)—— 物理层(1、2、3):物理层的基本概念、物理层的下面的传输媒体、传输方式
  19. 面试常见的逻辑推理题
  20. 国内可访问的免费离线下载网站 摘录

热门文章

  1. 新氧科技CEO金星直播背后:助推产业线上化,打造医美“新基建”
  2. DB数据库密码怎么破啊~~~求高手帮忙解决下~
  3. html p 会自动换行,css如何设置p标签不换行?
  4. 易车网李斌:一个放牛娃的梦想(转载)
  5. 超全汇总 | 基于Camera的3D目标检测算法综述!(单目/双目/伪激光雷达)
  6. [心得]毕业生租房经验总结
  7. 【读书总结】 《你只是看起来很努力》——致那段应该奋斗的岁月
  8. sql server 首字母大写
  9. maxwell采集mysql binlog 日志数据到kafka topic
  10. big code: Toward Deep Learning Software Repositories [MSR 2015]