Apporto & Python Modules

Body

Summary

When using python on Apporto you will more than likely use python modules. In order to use python modules you will have to use code below in order to do so. The reason why is because on the Apporto VM’s they do not allow you to install libraries on the c drive because of security purposes. You can however install libraries to your user drive.

How to install Modules

To install modules you will have to use pip to install them. 

 

Pip install (name of your packages

Example:

pip install psycopg2

 

Code for Python Script

You will need to add this code below to the top of your script to access the modules you installed.

 

Code:


import sys

package_directory = '/path/to/your/package/directory'

sys.path.append(package_directory)

# Now you can import modules from the specified directory

import my_module

# Rest of your script

 

 

Example:


import sys


package_directory = 'Z:/GVSU/Users/mccrakei_gvsu/AppData/Roaming/Python/Python311/site-packages'

sys.path.append(package_directory)


import psycopg2

 

(Please note where my username is “mccrakei_gvsu” will be changed to your username_gvsu.)

Details

Details

Article ID: 17242
Created
Fri 11/10/23 5:20 PM
Modified
Wed 12/4/24 9:54 AM