Packages
How to work with packages
DataCamp Workspace's cloud execution environments come pre-packaged with all the common data science and machine learning packages.
If you need additional packages, you can install these manually, but keep in mind that you will need to reinstall these packages every time you return to your workspace. It is therefore a good idea to keep track of additional package installs at the top of your notebook, so you can easily rerun the commands when you return to your workspace.

Python workspace

To see which packages are available in a Python workspace, run !pip freeze in a code cell. This will print out a list of all installed packages along with their version.
To install additional packages, run !pip install <name-of-pkg> e.g. !pip install pythonwhat in a code cell.

R workspace

To see which packages are available in an R workspace,
    Navigate to Help --> R Help (from the menu bar)
    In the help panel, follow, Reference --> Packages
To install additional packages, run install.packages("<name-of-pkg>") e.g. install.packages("praise") in the R console or in the source pane.
Add this code chunk at the top ofnotebook.Rmd to persist packages installed. This will create a local package library and set it as the default. Any packages installed subsequently will be installed to the local library. Moreoever, R will look for packages in this location first, before looking for it in the system library.
Note that R packages that install system dependencies might not work as intended.
1
if (!dir.exists('/work/files/rlibrary')){
2
dir.create('/work/files/rlibrary')
3
.libPaths(new = '/work/files/rlibrary')
4
}
5
6
# If you restart your session, you just need to run the line below
7
# .libPaths(new = '/work/files/rlibrary')
Copied!
​
Last modified 1mo ago