Installing Python packages

Global:
A public directory is available where instructors can install python packages for students to use. Once installed, these packages will be available for students and scripts to access in the course. There are some wrapper functions available to make this more convenient.
This is done via the terminal in the "Configure workspace" window. If you are running Jupyter or R-Studio, you can get a terminal by selecting "View =>Standard". Depending on the python version, the instructor needs to use the appropriate function for packages installation:
        vocpipinstall2.7 <pkgs>
        vocpipinstall3.5 <pkgs>
        vocpipinstall3.6 <pkgs>
The directories that these <pkgs> get installed in are already present in the PYTHONPATH for both teachers and students. Note that since all 3 python-version install paths are present in PYTHONPATH, if a pkg is installed for an unwanted version, it could get picked up for a different python version.
Local:
Packages can also be installed in the local directories by students (or instructors). However, if the student code uses a package that was installed locally, it may not be available during grading (unless the instructor or Vocareum installs it in a globally visible location).
To install a package locally, just use the appropriate pip version and specify the "--user" switch.
        pip3.6 install --user <pkg>

Packages can also be installed from within Jupyter notebooks. Since there are multiple python versions installed on the Vocareum servers, it is better to use the following command (instead of pip directly) so that the package is installed for the current notebook python version.

        import sys

        !{sys.executable} -m pip install --user <pkg>

Still need help? Contact Us Contact Us