1

如何在PyCharm中配置虚拟环境?

 1 year ago
source link: https://www.51cto.com/article/756457.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

如何在PyCharm中配置虚拟环境?

作者:黑马程序员 2023-06-01 15:37:11

若要使用PyCharm工具开发Flask程序,既可以另行创建新的虚拟环境,也可以使用创建好的虚拟环境进行开发。接下来,在PyCharm工具中新建一个项目,并为该项目配置虚拟环境flask_env。

若要使用PyCharm工具开发Flask程序,既可以另行创建新的虚拟环境,也可以使用创建好的虚拟环境进行开发。接下来,在PyCharm工具中新建一个项目,并为该项目配置虚拟环境flask_env。

首次打开PyCharm工具时会进入Welcome to PyCharm界面。

f48420e697a6fc27492145020e7e6e2153f8c8.jpg

单击Welcome to PyCharm界面中的“Create New Project"按钮进入New Project界面。

Location文本框用于填写项目的路径及名称,默认名称为untitled;Project Interpreter用于选择Python解释器,它包含New environmentusing和Existing interpreter两个选项,其中New environment using代表新创建的环境,Existinginterpreter代表已经存在的Python解释器。

5209e1373b9b5ae88f03835c545b6733cacda5.png

将项目的名称由untitled修改为first_pro,单击标注的...按钮弹出Add Python Interpreter窗口。

d1ed252262a1d66b926451fbde1dd66a41fc93.png

窗口左侧包含Virtualenv Environment、Conda Environment、 SystemInterpreter和Pipenv Environment共4个选项,其中Virtualenv Environment表示添加虚拟环境中的Python解释器,CondaEnvironment表示添加Conda环境中的Python解释器,System Interpreter表示添加本地的Python解释器。

单击Add Python Interpreter窗口中标注的...按钮,弹出Select Python Interpreter窗口,在该窗口中选择虚拟环境flask_env中的python.exe。

d7c9cc255b2d3ffe75b09577e932d3b3f0fe89.jpg

单击Select Python Interpreter窗口中的“OK”按钮,关闭Select Python Interpreter窗口,跳转回Add Python Interpreter窗口,在Add Python Interpreter窗口中单击"OK"按钮,关闭Add PythonInterpreter窗口并跳转回New Project界面,此时New Project界面中显示了选择的Python解释器。

75b56da00e23034b46128127fa4acabf16ff2a.png

单击New Project界面中的“Create”按钮,进入first_pro项目的主界面。

168757d36e02e5bbbac1853db36597117bf51a.png
责任编辑:华轩 来源: 今日头条

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK