在文中使用的集成开发环境(IDE)是Rstudio,code 表示代码(code)

R代码块中, #> 表示运行R代码输出的结果,如

Code
print("R")
#> [1] "R"

Python代码块中, #>>> 表示运行Python代码输出的结果,如

Code
print("Python")
###> Python

在 Rstudio Console 中交互式运行 Python

Code

Python包管理工具

Python package index(pypi) 是一个Python编程语言的软件库。

Anaconda

环境

pytorch
D:
cd anaconda3/envs
conda create -n pytorch python==3.11.7
conda acticate pytorch
conda install pythorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 cpuonly -c pytorch

gpt_academic
D:
cd anaconda3/envs
conda create -n gptac-venv python==3.11.7
conda acticate gptac-venv
cd gptac-venv 
git clone --depth==1 url.git
#复制gpt_academic中的requirements.txt文件到gptac-venv
python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
#修改config.py
cd gpt_academic
python main.py

D:
cd anaconda3/envs/gptac_venv/gpt_academic

conda activate gptac_venv

python main.py

pip

pip <command> [options]

pip install <module>

pip install SpeechRecognition -i https://pypi.tuna.tsinghua.edu.cn/simple/

pip uninstall <module>
pip list
pip --version pip -V
python -m pip install --upgrade pip

环境

Code
reticulate::py_config()
#> python:         D:/anaconda3/envs/speech_recognition/python.exe
#> libpython:      D:/anaconda3/envs/speech_recognition/python311.dll
#> pythonhome:     D:/anaconda3/envs/speech_recognition
#> version:        3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:27:59) [MSC v.1937 64 bit (AMD64)]
#> Architecture:   64bit
#> numpy:           [NOT FOUND]
#> 
#> NOTE: Python version was forced by RETICULATE_PYTHON_FALLBACK

reticulate::use_python("D:/anaconda3/envs/speech_recognition/python.exe")
Code
reticulate::py_config()
#> python:         D:/anaconda3/envs/speech_recognition/python.exe
#> libpython:      D:/anaconda3/envs/speech_recognition/python311.dll
#> pythonhome:     D:/anaconda3/envs/speech_recognition
#> version:        3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:27:59) [MSC v.1937 64 bit (AMD64)]
#> Architecture:   64bit
#> numpy:           [NOT FOUND]
#> 
#> NOTE: Python version was forced by RETICULATE_PYTHON_FALLBACK
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.3 (2024-02-29 ucrt)
#>  os       Windows 10 x64 (build 19045)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language en
#>  collate  Chinese (Simplified)_China.utf8
#>  ctype    Chinese (Simplified)_China.utf8
#>  tz       Asia/Shanghai
#>  date     2024-04-15
#>  pandoc   3.1.13 @ D:/anaconda3/envs/speech_recognition/Library/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  BiocManager * 1.30.22 2023-08-08 [1] CRAN (R 4.3.3)
#>  cachem        1.0.8   2023-05-01 [1] CRAN (R 4.3.3)
#>  cellranger    1.1.0   2016-07-27 [1] CRAN (R 4.3.3)
#>  cli           3.6.2   2023-12-11 [1] CRAN (R 4.3.3)
#>  codetools     0.2-20  2024-03-31 [1] CRAN (R 4.3.3)
#>  colorspace    2.1-0   2023-01-23 [1] CRAN (R 4.3.3)
#>  conflicted  * 1.2.0   2023-02-01 [1] CRAN (R 4.3.3)
#>  devtools      2.4.5   2022-10-11 [1] CRAN (R 4.3.3)
#>  digest        0.6.35  2024-03-11 [1] CRAN (R 4.3.3)
#>  dplyr       * 1.1.4   2023-11-17 [1] CRAN (R 4.3.3)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.3.3)
#>  evaluate      0.23    2023-11-01 [1] CRAN (R 4.3.3)
#>  fansi         1.0.6   2023-12-08 [1] CRAN (R 4.3.3)
#>  fastmap       1.1.1   2023-02-24 [1] CRAN (R 4.3.3)
#>  forcats     * 1.0.0   2023-01-29 [1] CRAN (R 4.3.3)
#>  fs            1.6.3   2023-07-20 [1] CRAN (R 4.3.3)
#>  generics      0.1.3   2022-07-05 [1] CRAN (R 4.3.3)
#>  ggplot2     * 3.5.0   2024-02-23 [1] CRAN (R 4.3.3)
#>  glue          1.7.0   2024-01-09 [1] CRAN (R 4.3.3)
#>  gtable        0.3.4   2023-08-21 [1] CRAN (R 4.3.3)
#>  here          1.0.1   2020-12-13 [1] CRAN (R 4.3.3)
#>  hms           1.1.3   2023-03-21 [1] CRAN (R 4.3.3)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.3.3)
#>  htmlwidgets   1.6.4   2023-12-06 [1] CRAN (R 4.3.3)
#>  httpuv        1.6.15  2024-03-26 [1] CRAN (R 4.3.3)
#>  jsonlite      1.8.8   2023-12-04 [1] CRAN (R 4.3.3)
#>  knitr         1.45    2023-10-30 [1] CRAN (R 4.3.3)
#>  later         1.3.2   2023-12-06 [1] CRAN (R 4.3.3)
#>  lattice       0.22-6  2024-03-20 [1] CRAN (R 4.3.3)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.3.3)
#>  lubridate   * 1.9.3   2023-09-27 [1] CRAN (R 4.3.3)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.3.3)
#>  Matrix        1.6-5   2024-01-11 [1] CRAN (R 4.3.3)
#>  memoise       2.0.1   2021-11-26 [1] CRAN (R 4.3.3)
#>  mime          0.12    2021-09-28 [1] CRAN (R 4.3.1)
#>  miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.3.3)
#>  munsell       0.5.1   2024-04-01 [1] CRAN (R 4.3.3)
#>  patchwork   * 1.2.0   2024-01-08 [1] CRAN (R 4.3.3)
#>  pillar        1.9.0   2023-03-22 [1] CRAN (R 4.3.3)
#>  pkgbuild      1.4.4   2024-03-17 [1] CRAN (R 4.3.3)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.3.3)
#>  pkgload       1.3.4   2024-01-16 [1] CRAN (R 4.3.3)
#>  png           0.1-8   2022-11-29 [1] CRAN (R 4.3.1)
#>  profvis       0.3.8   2023-05-02 [1] CRAN (R 4.3.3)
#>  promises      1.3.0   2024-04-05 [1] CRAN (R 4.3.3)
#>  purrr       * 1.0.2   2023-08-10 [1] CRAN (R 4.3.3)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.3.3)
#>  Rcpp          1.0.12  2024-01-09 [1] CRAN (R 4.3.3)
#>  readr       * 2.1.5   2024-01-10 [1] CRAN (R 4.3.3)
#>  readxl      * 1.4.3   2023-07-06 [1] CRAN (R 4.3.3)
#>  remotes       2.5.0   2024-03-17 [1] CRAN (R 4.3.3)
#>  reticulate    1.35.0  2024-01-31 [1] CRAN (R 4.3.3)
#>  rlang         1.1.3   2024-01-10 [1] CRAN (R 4.3.3)
#>  rmarkdown     2.26    2024-03-05 [1] CRAN (R 4.3.3)
#>  rprojroot     2.0.4   2023-11-05 [1] CRAN (R 4.3.3)
#>  rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.3.3)
#>  scales        1.3.0   2023-11-28 [1] CRAN (R 4.3.3)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.3.3)
#>  shiny         1.8.1.1 2024-04-02 [1] CRAN (R 4.3.3)
#>  stringi       1.8.3   2023-12-11 [1] CRAN (R 4.3.2)
#>  stringr     * 1.5.1   2023-11-14 [1] CRAN (R 4.3.3)
#>  tibble      * 3.2.1   2023-03-20 [1] CRAN (R 4.3.3)
#>  tidyr       * 1.3.1   2024-01-24 [1] CRAN (R 4.3.3)
#>  tidyselect    1.2.1   2024-03-11 [1] CRAN (R 4.3.3)
#>  tidyverse   * 2.0.0   2023-02-22 [1] CRAN (R 4.3.3)
#>  timechange    0.3.0   2024-01-18 [1] CRAN (R 4.3.3)
#>  tzdb          0.4.0   2023-05-12 [1] CRAN (R 4.3.3)
#>  urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.3.3)
#>  usethis       2.2.3   2024-02-19 [1] CRAN (R 4.3.3)
#>  utf8          1.2.4   2023-10-22 [1] CRAN (R 4.3.3)
#>  vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.3.3)
#>  withr         3.0.0   2024-01-16 [1] CRAN (R 4.3.3)
#>  writexl     * 1.5.0   2024-02-09 [1] CRAN (R 4.3.3)
#>  xfun          0.43    2024-03-25 [1] CRAN (R 4.3.3)
#>  xtable        1.8-4   2019-04-21 [1] CRAN (R 4.3.3)
#>  yaml          2.3.8   2023-12-11 [1] CRAN (R 4.3.2)
#> 
#>  [1] D:/R-4.3.3/library
#> 
#> ─ Python configuration ───────────────────────────────────────────────────────
#>  python:         D:/anaconda3/envs/speech_recognition/python.exe
#>  libpython:      D:/anaconda3/envs/speech_recognition/python311.dll
#>  pythonhome:     D:/anaconda3/envs/speech_recognition
#>  version:        3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:27:59) [MSC v.1937 64 bit (AMD64)]
#>  Architecture:   64bit
#>  numpy:           [NOT FOUND]
#>  
#>  NOTE: Python version was forced by RETICULATE_PYTHON_FALLBACK
#> 
#> ──────────────────────────────────────────────────────────────────────────────