Anaconda3与PyCharm安装配置

发布于:2024-10-17 ⋅ 阅读:(41) ⋅ 点赞:(0)

参考文章

Anaconda3与PyCharm安装配置保姆教程

参照上面文章,安装好Anaconda3和PyCharm环境

下面重点记录下环境配置

1,在window系统菜单中选择Anaconda Prompt,而不是Anaconda Powershell Prompt

2, 打开Anaconda Prompt,输入conda,则有如下输出

(base) C:\Users\lenovo>conda
usage: conda-script.py [-h] [-v] [--no-plugins] [-V] COMMAND ...

conda is a tool for managing and deploying applications, environments and packages.

options:
  -h, --help          Show this help message and exit.
  -v, --verbose       Can be used multiple times. Once for detailed output, twice for INFO logging, thrice for DEBUG
                      logging, four times for TRACE logging.
  --no-plugins        Disable all plugins that are not built into conda.
  -V, --version       Show the conda version number and exit.

commands:
  The following built-in and plugins subcommands are available.

  COMMAND
    activate          Activate a conda environment.
    build             Build conda packages from a conda recipe.
    clean             Remove unused packages and caches.
    commands          List all available conda subcommands (including those from plugins). Generally only used by tab-
                      completion.
    compare           Compare packages between conda environments.
    config            Modify configuration values in .condarc.
    content-trust     Signing and verification tools for Conda
    convert           Convert pure Python packages to other platforms (a.k.a., subdirs).
    create            Create a new conda environment from a list of specified packages.
    deactivate        Deactivate the current active conda environment.
    debug             Debug the build or test phases of conda recipes.
    develop           Install a Python package in 'development mode'. Similar to `pip install --editable`.
    doctor            Display a health report for your environment.
    export            Export a given environment
    index             Update package index metadata files.
    info              Display information about current conda install.
    init              Initialize conda for shell interaction.
    inspect           Tools for inspecting conda packages.
    install           Install a list of packages into a specified conda environment.
    list              List installed packages in a conda environment.
    metapackage       Specialty tool for generating conda metapackage.
    notices           Retrieve latest channel notifications.
    pack              See `conda pack --help`.
    package           Create low-level conda packages. (EXPERIMENTAL)
    remove (uninstall)
                      Remove a list of packages from a specified conda environment.
    rename            Rename an existing environment.
    render            Expand a conda recipe into a platform-specific recipe.
    repo              See `conda repo --help`.
    repoquery         Advanced search for repodata.
    run               Run an executable in a conda environment.
    search            Search for packages and display associated information using the MatchSpec format.
    server            See `conda server --help`.
    skeleton          Generate boilerplate conda recipes.
    token             See `conda token --help`.
    update (upgrade)  Update conda packages to the latest compatible version.

3,接着再输入python,看到如下:

(base) C:\Users\lenovo>python
Python 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:03:56) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

然后输出exit()推出。

4,继续在conda终端,执行conda create -n face_env python=3.8, 回车创建face_env环境变量,python版本3.8

(base) C:\Users\lenovo>conda create -n face_env python=3.8
Channels:
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
 - defaults
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\lenovo\.conda\envs\face_env

  added / updated specs:
    - python=3.8


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2024.9.24  |       haa95532_0         131 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    libffi-3.4.4               |       hd77b12b_1         122 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    openssl-3.0.15             |       h827c3e9_0         7.8 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    pip-24.2                   |   py38haa95532_0         2.4 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    python-3.8.20              |       h8205438_0        19.4 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    setuptools-75.1.0          |   py38haa95532_0         1.6 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    sqlite-3.45.3              |       h2bbff1b_0         973 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    vc-14.40                   |       h2eaa2aa_1          10 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    vs2015_runtime-14.40.33807 |       h98bb1dd_1         1.3 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    wheel-0.44.0               |   py38haa95532_0         137 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    ------------------------------------------------------------
                                           Total:        33.8 MB

The following NEW packages will be INSTALLED:

  ca-certificates    anaconda/pkgs/main/win-64::ca-certificates-2024.9.24-haa95532_0
  libffi             anaconda/pkgs/main/win-64::libffi-3.4.4-hd77b12b_1
  openssl            anaconda/pkgs/main/win-64::openssl-3.0.15-h827c3e9_0
  pip                anaconda/pkgs/main/win-64::pip-24.2-py38haa95532_0
  python             anaconda/pkgs/main/win-64::python-3.8.20-h8205438_0
  setuptools         anaconda/pkgs/main/win-64::setuptools-75.1.0-py38haa95532_0
  sqlite             anaconda/pkgs/main/win-64::sqlite-3.45.3-h2bbff1b_0
  vc                 anaconda/pkgs/main/win-64::vc-14.40-h2eaa2aa_1
  vs2015_runtime     anaconda/pkgs/main/win-64::vs2015_runtime-14.40.33807-h98bb1dd_1
  wheel              anaconda/pkgs/main/win-64::wheel-0.44.0-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

5,在conda终端执行激活环境指令 conda activate face_env,则出现如下.

(base) C:\Users\lenovo>conda activate face_env

(face_env) C:\Users\lenovo>

注意环境变量从basse 变成了face_env

6,在conda终端执行安装python依赖包指令,指令如下.

(face_env) C:\Users\lenovo>    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python pyqt5
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting opencv-python
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/6c/fab8113424af5049f85717e8e527ca3773299a3c6b02506e66436e19874f/opencv_python-4.10.0.84-cp37-abi3-win_amd64.whl (38.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.8/38.8 MB 727.5 kB/s eta 0:00:00
Collecting pyqt5
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/56/d5/68eb9f3d19ce65df01b6c7b7a577ad3bbc9ab3a5dd3491a4756e71838ec9/PyQt5-5.15.11-cp38-abi3-win_amd64.whl (6.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.9/6.9 MB 180.0 kB/s eta 0:00:00
Collecting numpy>=1.17.0 (from opencv-python)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/69/65/0d47953afa0ad569d12de5f65d964321c208492064c38fe3b0b9744f8d44/numpy-1.24.4-cp38-cp38-win_amd64.whl (14.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.9/14.9 MB 559.1 kB/s eta 0:00:00
Collecting PyQt5-sip<13,>=12.15 (from pyqt5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4f/fc/7d44e8f83eded93fa1517d8354529b7a21cae5d93c26e1681fd7e4bcbb2b/PyQt5_sip-12.15.0-cp38-cp38-win_amd64.whl (59 kB)
Collecting PyQt5-Qt5<5.16.0,>=5.15.2 (from pyqt5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/37/97/5d3b222b924fa2ed4c2488925155cd0b03fd5d09ee1cfcf7c553c11c9f66/PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 50.1/50.1 MB 705.9 kB/s eta 0:00:00
Installing collected packages: PyQt5-Qt5, PyQt5-sip, numpy, pyqt5, opencv-python
Successfully installed PyQt5-Qt5-5.15.2 PyQt5-sip-12.15.0 numpy-1.24.4 opencv-python-4.10.0.84 pyqt5-5.15.11

可以看到Successfully installed PyQt5-Qt5-5.15.2等字样,成功安装项目所需的python环境与依赖包.

7,PyCharm配置虚拟环境

打开PyCharm,打开或新建一个项目,在Flie->settings打开设置对话框,然后左侧项目下拉列表中选中Python解释器,然后右侧点击添加解释器对话框


网站公告

今日签到

点亮在社区的每一天
去签到