Python Embedded in Gams - Import Python Package

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
polppp
User
User
Posts: 3
Joined: 3 months ago

Python Embedded in Gams - Import Python Package

Post by polppp » 2 months ago

When I am using embedded python code in GAMS can I import python packages such as pandas some how? When I am just normally write :

$onEmbeddedCode Python:
import pandas as pd

I get an 865 Problem in Embedded Code Section

Thank you

Freddy
User
User
Posts: 4
Joined: 5 months ago

Re: Python Embedded in Gams - Import Python Package

Post by Freddy » 2 months ago

Yes you can. Either install the package manually by navigating to your GMSPython folder (i.e. <GAMSRoot>/GMSPython) and using the pip executable (python package management system). This tool should be located in a folder "Scripts" or something similar. (you can install pandas with pip with the command: "pip install pandas") Alternatively use the solution proposed here to import packages from within your code: https://stackoverflow.com/questions/123 ... ithin-code

Post Reply