Installing Python Packages

Installing Python Packages

译者:徐静

Conda installation

下面这些函数可以管理Conda环境

Function Description
conda_list() List all available conda environments
conda_create() Create a new conda environment
conda_install() Install a package within a conda environment
conda_remove() Remove individual packages or an entire conda environment

例子:

library(reticulate)

# create a new environment 
conda_create("r-reticulate")

# install SciPy
conda_install("r-reticulate", "scipy")

# import SciPy (it will be automatically discovered in "r-reticulate")
scipy <- import("scipy")


library(reticulate)

# indicate that we want to use a specific condaenv
use_condaenv("r-reticulate")

# import SciPy (will use "r-reticulate" as per call to use_condaenv)
scipy <- import("scipy")

虚拟环境安装

下面这些函数管理Python虚拟环境

Function Description
virtualenv_list() List all available virtualenvs
virtualenv_create() Create a new virtualenv
virtualenv_install() Install a package within a virtualenv
virtualenv_remove() Remove individual packages or an entire virtualenv

例子:

library(reticulate)

# create a new environment 
virtualenv_create("r-reticulate")

# install SciPy
virtualenv_install("r-reticulate", "scipy")

# import SciPy (it will be automatically discovered in "r-reticulate")
scipy <- import("scipy")

library(reticulate)

# indicate that we want to use a specific virtualenv
use_virtualenv("r-reticulate")

# import SciPy (will use "r-reticulate" as per call to use_virtualenv)
scipy <- import("scipy")


Shell安装

# install into system level Python
$ sudo pip install SciPy

# install into active Conda environment
$ conda install SciPy

Reference

[1].Installing Python Packages(en)

Author face

徐静

数据科学从业者,算法工程师. 善于用数据科学的工具透析业务,模型的线上化部署,网络爬虫及前端可视化. 喜欢研究机器学习,深度学习及相关软件实现.目前自己还是小白一个,希望多多学习.

最近发表的文章