Creation of tensorflow virtual environment under Anaconda, and some command line code notes

 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

[anaconda] conda creates, views, and deletes virtual environments (anaconda command set)_View conda virtual environment_miracleo_'s blog-CSDN blog

 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.

tensorflow · PyPI

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

Guess you like

Origin blog.csdn.net/qq_44874004/article/details/130587429