1. Create a virtual environment
1.1 View the installed environment
The "*" on the right indicates the current environment.
conda env list
Some other commonly used commands:
Delete an environment:conda env remove -n flowers
View all installed packages:conda list
Uninstall package:conda remove package-name
1.2 Create tensorflow environment
Enter the command: conda create -n tensorflow python=3.7, which means to create an environment named tensorflow. The python version used in this environment is version 3.7.
conda create -n tensorflow python=3.7
1.3 Enter the environment
Enter the command: activate tensorflow to enter the tensorflow environment
1.4 Install the specified version of tensorflow
pip install tensorflow==2.8.0
What I installed here is version 2.8. You can go to the official website to find the installation command for the version you need.
When using Python, you need to export the installed Package through requirements.txt, and you can deploy a new environment with one command.
requirements.txt is used to record all dependent packages and their precise version numbers.
Step 1: Automatically generate the requirement.txt command:
pip freeze > requirements.txt
1
After successful execution, the requirement.txt file will be automatically generated at the same level as the Python file.
Step 2: Change the environment
When sharing Python files,
remember to also bring the requirement.txt file!
Step 3: Install requirement.txt in the new environment,
Execute the command to install the required third-party libraries with one click.
pip install -r requirements.txt