Python environment configuration and Ubuntu dual system installation

Learn Markdown grammar Markdown grammar learning

       Conda itself is a tool, similar to pip (it is a package and a tool), but it is more powerful and easy to use than pip, because conda can also manage different environments. Each environment has its own independent library, package, and python interpreter (you can specify which version of the python interpreter to create when creating a new environment with conda).

       My understanding of anaconda is that it is a multi-functional integrated software for python. Anaconda includes editors such as jupyter and comes with a base environment with a python3.7 interpreter. This base environment is pre-installed Many packages, including toolkits like conda and pip, and common packages like numpy.

       Of course, we generally use the pycharm editor + anaconda solution. In pycharm, you can use the conda tool to create a new environment and specify the python interpreter version of the new environment, but the conda tool used, that is, the conda executable, is all Scripts in the anaconda installation path conda.exe in. When creating a new environment, if you don’t check make available to all projects, only your own current project can use the created virtual environment. When you open pycharm to select other projects in the future, you will not be able to choose to use your virtual environment, so I still feel It is better to check it, so that other projects can also use this environment. Each environment has its own python interpreter, and the version can be different.

       If you want to use the base environment, select Previously configured interpreter when creating the environment, that is, the existing interpreter, and then the conda executable is the same as conda.exe in the Scripts file, and then Use existing environment directly Select the installation path of anaconda, which is the base environment.

       When installing annaconda or after installation, it is best to add annaconda to the environment variables of the system , so that the conda command can be used in the cmd command line and terminal, otherwise the command will not be recognized.

       In fact, if we use it ourselves, a miniconda is enough.

       After creating a new environment, you can install a numpy library to try it out, first open the anaconda prompt, (you can change the source first), use the conda activate environment name to enter the environment, and then conda install numpy installation.

       It seems that opencv-python can only be installed with pip. pip install opnecv-python

       pip change source pip one-click command line change source

       Conda source change pip, conda source change to Tsinghua source, view source, delete source

Conda common commands

Enter through the anaconda prompt command line

For Ubuntu dual system installation, refer to the video of dual system , which is very good. For the method of entering the bios installation through the U disk system disk of the 2019 model, refer to this article Lenovo y7000pbios .

Conda comes with some packages, which are placed under the base environment. If you build a new environment yourself, many packages need to be installed by yourself.

Each python environment has its own python interpreter (you can specify the version yourself). You can specify the python version when creating it. If you don’t specify it, it should be the default. If you create a new environment in pycharm, it seems that there are not many versions to choose from.

If you do not check make available to all project, only your own current project can use the created virtual environment, and you will not be able to choose to use your virtual environment when you open pycharm to select other projects in the future. So tick it anyway.

Remember to change the source for conda and pip

conda usage

The general process of pytorch and cuda installation

Xiaobai friends, don’t bother with these drivers such as cuDNN, the simplest gpu pytorch installation tutorial:
1. Enter nvidia-smi in cmd to see the cuda version in the upper right corner
2. Install anaconda or miniconda and change the domestic source
3. Open the anaconda prompt to create a virtual Python environment:
conda create -n environment name python=3.8
4. Activation environment:
conda activate environment name
5. Go to pytorch official website to select the corresponding pytorch gpu version For example:
conda install pytorch torchvision torchaudio cudatoolkit=11.3
(remove -c pytorch is said to be Download faster)
6. After the installation is complete, check whether the verification is successful, and then enter:
ipython, press Enter,
import torch, press Enter,
torch.cuda.is_available(), press Enter
, if the output is True, it is all right

 Anaconda+PyCharm creation environment and configuration environment

Guess you like

Origin blog.csdn.net/weixin_47441391/article/details/127252695