python日记2 terminal package file

Python(2)
关键词
pycharm use anaconda environment
terminal
package
file

1.create conda virtual environment
在terminal中
conda create --name aisafety python=3.8
在anaconda中的environment里可以查看到(也许可以直接在这里新建?)
在这里插入图片描述在这里插入图片描述

2. 在pycahrm中新建project,用anaconda环境

在这里插入图片描述可以在file>settings>project:>python interpreter 中修改
3. import package

在pycharm中
import numpy
直接点击提示install package

在terminal中
conda activate aisafety
conda install numpy

*如果是matlpotlib等不能直接安装的package(见python日记1)
在terminal中
conda activate aisafety
pip install matlpotlib

*测试是否已安装成功
pycharm直接run
terminal输入

>python
>import numpy

4. 在terminal中运行.py file
conda activate aisafety
mac貌似可以直接python +file name
在这里插入图片描述
我的需要输入python+path
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Flask is a lightweight and flexible Python web framework that provides useful tools and features for building web applications. To create a Flask file, you need to follow these steps: 1. Install Flask: You can install Flask using pip, a package manager for Python. Open your terminal or command prompt and type the following command: ``` pip install flask ``` 2. Create a new file: Open your text editor and create a new file. Save the file with a .py extension, such as app.py. 3. Import Flask: In the file, import Flask by adding the following line at the top of the file: ```python from flask import Flask ``` 4. Create an instance of the Flask class: Create an instance of the Flask class by adding the following line: ```python app = Flask(__name__) ``` The __name__ argument is used by Flask to determine the root path of the application. 5. Define a route: Define a route by adding a function with the @app.route decorator. The route specifies the URL that the function should respond to. For example, the following function responds to requests at the root URL: ```python @app.route('/') def hello_world(): return 'Hello, World!' ``` 6. Run the application: Run the application by adding the following line at the bottom of the file: ```python if __name__ == '__main__': app.run() ``` This code checks if the file is being executed as the main program, and starts the Flask development server if it is. Here's an example of a simple Flask file: ```python from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, World!' if __name__ == '__main__': app.run() ``` To run the file, open your terminal or command prompt and navigate to the directory where the file is saved. Then type the following command: ``` python app.py ``` This will start the Flask development server. Open your web browser and go to http://localhost:5000 to see the application in action.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值