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.
You should 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 and to ensure that workspace publications can complete without issues.

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, add !pip install <name-of-pkg> e.g. !pip install pythonwhat in a code cell.

R workspace

To install additional packages, add install.packages("<name-of-pkg>") e.g. install.packages("praise") in a code chunk at the top of your notebook and run the code chunk.
Pro tip: 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 5d ago