Anaconda3 and PyCharm installation and configuration nanny tutorial

foreword

As a scientific research instructor, I found in the daily teaching process that when many students learn AI artificial intelligence for the first time, some do not know how to build the relevant development environment, and some have various strange problems in the operation of the development environment. Most of them are problems that Python code cannot run, and 80% of these are caused by incorrect environment configuration. To sum up, the main reason is that many students do not know how to install their environment configuration or do not notice some details because they are new to Python. There are many reasons for this, such as network, dependencies, dependent package versions, Python versions, installation methods and Computer configuration, etc. will affect the installation of third-party libraries. This article introduces in detail how to install Anaconda3 and PyCharm, two necessary software for Python development, on Win10/Win11 systems. Each step in the article has detailed screenshots and step-by-step explanations. Finally, it introduces how to use Anaconda3 to create a virtual environment and configure the environment in PyCharm . The provided software installation steps have been tested in the Win10 system. At present, many students have been guided to successfully install it. Here are the specific steps for the reference of new students.

1. Anaconda3 installation

1.1 Download the installation package

(1) First download the installation program of Anaconda3, and download it from Anaconda's official website https://www.anaconda.com/ , as shown in the figure below, enter the homepage of the official website and click "Download".

insert image description here
(2) Enter the homepage of the official website and click "Download", and then the browser page switches to the page shown in the figure below. (
insert image description here
3) Then wait for the browser to download, the downloaded installation program is shown in the figure below, and then you can double-click to start Install.
insert image description here

1.2 Installation steps

(1) Double-click the installer, and click "Next" as follows.
insert image description here
(2) Click "I Agree" to agree to the software agreement, as shown in the figure below.
insert image description here
(3) Select the installation user. For personal computers, you can choose one of them. If there is For multi-user computers, select "All Users", then click "Next" to continue the installation.
insert image description here

(4) Select the installation path, click "Browse" and the "Browse Folder" window will pop up, select your own installation directory, such as "C:\anaconda3" here. Note that there should be no Chinese path in the installation location, and the disk should be large enough , as shown in the figure below.
insert image description here
(5) The installation options are as shown in the figure below, using the default two options, and finally click "Install" to start the installation. Note, it is not recommended for beginners to tick Select the "Add Anaconda3 environment to the environment variable" option to open the conda terminal through Anaconda Prompt .
insert image description here

(6) Start the installation, and the progress bar starts. This step only needs to wait for the progress bar to end. The time depends on the configuration of the personal computer. The higher the configuration, the faster the installation. (7) After the progress bar reaches the end, click "Next" to continue to the next
insert image description here
step .
insert image description here
(8) Click "Next" to continue to the next step.
insert image description here
(9) Click "Finish" to complete the software installation.
insert image description here

1.3 Test installation

(1) Select Anaconda Prompt in the window system menu, as shown in the figure below.
insert image description here
(2) Open Anaconda Prompt, enter conda, and the following output will appear.

(base) C:\Users\tanggt>conda
usage: conda-script.py [-h] [-V] command ...
conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command
    clean             Remove unused packages and caches.
    compare           Compare packages between conda environments.
    config            Modify configuration values in .condarc. This is modeled after the git config command. Writes to
                      the user .condarc file (C:\Users\tanggt\.condarc) by default. Use the --show-sources flag to
                      display all identified configuration locations on your computer.
    create            Create a new conda environment from a list of specified packages.
    info              Display information about current conda install.
    init              Initialize conda for shell interaction.
    install           Installs a list of packages into a specified conda environment.
    list              List installed packages in a conda environment.
    package           Low-level conda package utility. (EXPERIMENTAL)
    remove (uninstall)
                      Remove a list of packages from a specified conda environment. Use `--all` flag to remove all
                      packages and the environment itself.
    rename            Renames an existing environment.
    run               Run an executable in a conda environment.
    search            Search for packages and display associated information.The input is a MatchSpec, a query
                      language for conda packages. See examples below.
    update (upgrade)  Updates conda packages to the latest compatible version.
    notices           Retrieves latest channel notifications.

options:
  -h, --help          Show this help message and exit.
  -V, --version       Show the conda version number and exit.

conda commands available from other packages (legacy):
  build
  content-trust
  convert
  debug
  develop
  env
  index
  inspect
  metapackage
  pack
  render
  repo
  server
  skeleton
  token
  verify

(3) Open Anaconda Prompt, enter the base virtual environment by default , and enter python, as shown in the figure below.
insert image description here(4) If you successfully complete the above steps, congratulations, you have successfully installed the Anaconda3 development environment on your computer.

2. PyCharm installation

2.1 Download the installation package

(1) Similar to installing Anaconda3, first download the installation program of PyCharm, and download it from Pycharm's official website ( https://www.jetbrains.com/pycharm/ ), as shown in the figure below
insert image description here
(2) Enter the homepage of the official website and click "Download" , and then the browser jumps to the PyCharm version selection page, which is actually the real download page. Select the "Community" (community version) download button to start downloading the installation package. The community version is completely free, while the "Professional" (professional version) on the left is charged. Of course, with the blogger's years of development and teaching experience, the Pycharm community version is completely sufficient. (3) After clicking "Download" again
insert image description here
, Switch the page to the following page, and wait for the browser to download.
insert image description here
(4) After the download is complete, the back-end installation package is shown in the figure below.
insert image description here

2.2 Installation steps

(1) Double-click the installer, the following installation wizard will pop up, click "Next".
insert image description here
(2) Select the installation directory, then click "Browse", select the path to be installed in the pop-up "Browse folder" box, beginners can directly default That's it , then click "Next", as shown in the figure below.
insert image description here
(3) Select the installation option, check "Create shortcut", click "Next" to continue the installation.
insert image description here
(4) Click "Install" directly in this step to officially start Installation progress bar.
insert image description here
(6) When the progress bar is 100%, the software package installation is over, click "Finish" on the interface as shown below to end the installation. (
insert image description here
7) Start PyCharm, and the PyCharm startup page will pop up, as shown in the figure below.
insert image description here
(8) In Check "Agree Agreement" in the pop-up agreement window, and then click "Continue".
insert image description here
(9) Check "Don't Send" in the pop-up data sharing window, and then click "Continue".
insert image description here
(10) Finally, the main interface of PyCharm operation pops up , as shown in the figure below.
insert image description here
(11) If you successfully complete the above steps, congratulations, you have successfully installed the Pycharm development environment on your computer.

3. Configure the Conda environment in PyCharm

3.1 Open the project

In the introduction of the previous two sections, we have installed Anaconda and PyCharm. Next, we will introduce how to create a new Conda environment with a specific example, and then configure and use the environment in PyCharm.

(1) First of all, I found a Python project taught here to demonstrate to you, such as my folder below:
insert image description here
(2) Double-click the PyCharm icon on the desktop to start PyCharm, select "Open" on the navigation page, and it will open The folder option box pops up, select the project folder just now, such as "faceRecognition" here, and then click "OK".
insert image description here
Note that if the navigation page does not appear in this step, you can find "File" in the menu bar on the upper left of the software , and then click "Open", the folder will also pop up to select the path of the project.
insert image description here

(3) Open the project for the first time, PyCharm will pop up an interface whether to trust the project, we can click "Trust Project". (4
insert image description here
) After clicking "Trust Project", enter the main interface of PyCharm to open the project.
insert image description here

3.2 Create a Conda virtual environment

(1) Open Anaconda Prompt, as shown in the figure below.
insert image description here
(2) After opening Anaconda Prompt, enter the conda terminal, as shown in the figure below.
insert image description here
(3) In the conda terminal, execute conda create -n face_env python=3.8 and press Enter, then appears as follows.

(base) C:\Users\tanggt>conda create -n face_env python=3.8
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##

  environment location: C:\anaconda3\envs\face_env

  added / updated specs:
    - python=3.8


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2023.05.30 |       haa95532_0         120 KB
    libffi-3.4.4               |       hd77b12b_0         113 KB
    openssl-3.0.8              |       h2bbff1b_0         7.4 MB
    pip-23.1.2                 |   py38haa95532_0         2.8 MB
    python-3.8.16              |       h1aa4202_4        18.9 MB
    setuptools-67.8.0          |   py38haa95532_0         1.0 MB
    sqlite-3.41.2              |       h2bbff1b_0         894 KB
    wheel-0.38.4               |   py38haa95532_0          83 KB
    ------------------------------------------------------------
                                           Total:        31.3 MB

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/win-64::ca-certificates-2023.05.30-haa95532_0
  libffi             pkgs/main/win-64::libffi-3.4.4-hd77b12b_0
  openssl            pkgs/main/win-64::openssl-3.0.8-h2bbff1b_0
  pip                pkgs/main/win-64::pip-23.1.2-py38haa95532_0
  python             pkgs/main/win-64::python-3.8.16-h1aa4202_4
  setuptools         pkgs/main/win-64::setuptools-67.8.0-py38haa95532_0
  sqlite             pkgs/main/win-64::sqlite-3.41.2-h2bbff1b_0
  vc                 pkgs/main/win-64::vc-14.2-h21ff451_1
  vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.27.29016-h5e58377_2
  wheel              pkgs/main/win-64::wheel-0.38.4-py38haa95532_0


Proceed ([y]/n)? y


Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate face_env
#
# To deactivate an active environment, use
#
#     $ conda deactivate

(4) Execute the activation environment command conda activate face_env on the terminal , and the following will appear.
insert image description here
(5) Execute the installation python dependency package command on the conda terminal, the command is as follows.

    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python pyqt5

(6) Then, after pressing Enter, the relevant dependent packages will be automatically downloaded and installed, as shown in the figure below
insert image description here
(7) After execution, we have successfully installed the python environment and dependent packages required by the project.

3.3 PyCharm configures the virtual environment

(1) Start configuring the environment. Click the "File" menu and select the "Setting" option, as shown in the figure below.
insert image description here
(2) Find "Python Interpreter" in "Project", and the python environment is displayed as the base environment of conda, as shown in the figure below.
insert image description here
(3) Click **"Add Interpreter" in "Setting" , as shown in the figure below.
insert image description here
(4) Find "Conda Environment" in the "Add Python Interpreter" page, the latest version of PyCharm defaults to
Conda executable is not found as shown in the figure below.
insert image description here
(5) On the "Add Python Interpreter" page, manually configure "Conda executable", as shown in the figure below.
insert image description here
(6) Then, click
Load environments**, as shown in the figure below.
insert image description here
(7) Then, in the "Add Python Interpreter " page, select the face_env environment we created, click "OK", as shown in the figure below.
insert image description here
(8) Then, return to the "Setting" configuration page, as shown in the figure below.
insert image description here

insert image description here
You can start the project, as shown in the figure below.
insert image description here
(11) Wait until the project loads relevant resources. If there is no problem, the operation is successful, as shown in the figure below.
insert image description here

conclusion

Due to the limited ability of bloggers, the methods mentioned in this article will inevitably have omissions. I hope you can enthusiastically point out the mistakes, so that the next revision can be presented to everyone in a more perfect and rigorous manner. before. There are also many online tutorials for installing Python software. The installation steps do not have to be the same. Due to various factors, different people may have different installations. Therefore, it is normal if the installation fails. Keep calm and solve the problem. Most importantly, if there is a better way to achieve it, please let me know.

Guess you like

Origin blog.csdn.net/weixin_40280870/article/details/131234432