A few weeks ago, I wrote a post on how to set up your machine to run Python Data functions in Spotfire. This post will follow up on that by explaining the next step — how to install Python packages in Spotfire. Read on to learn how.
Prerequisites
Depending on your version of Python/Spotfire, you may need to install pip. Pip is a package management system used to install and manage Python packages. You can’t install packages without it. I am running Spotfire 10.2 with Python 2.7.7, as shown in the data function dialog (from the Data menu – Data function properties – Register new), so I need to install pip. For more information, check out this link.
Another indicator pip is needed is the lack of a “Scripts” folder as shown here. If you don’t have this folder, install pip.
![](https://www.bigmountainanalytics.com/wp-content/uploads/2019/10/scripts-folder-1.png)
Installing Pip
To install pip, first find where Python is installed. You are looking for this executable. Copy the file location.
![](https://www.bigmountainanalytics.com/wp-content/uploads/2019/10/python-location2.png)
If you are having trouble finding it, type “python.exe” into your windows search.
![](https://www.bigmountainanalytics.com/wp-content/uploads/2019/10/findpython.png)
Then, open up a command line. Just to be safe, I would run it as an administrator.
![](https://www.bigmountainanalytics.com/wp-content/uploads/2019/10/open-command.png)
Next, we will run the two commands shown below, one after the other.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
Note, if you aren’t in the command line at the right place, then you’ll get an error on the second command that looks like this. The errror says “invalid syntax”.
![](https://www.bigmountainanalytics.com/wp-content/uploads/2019/10/error.png)
In that case, change the location where pip is being installed using “cd ” and the location of your python installation as shown below.
![](https://www.bigmountainanalytics.com/wp-content/uploads/2019/10/location.png)
Installing Packages
With pip setup, you can install packages with the simple command shown below.
pip install pandas
![](https://www.bigmountainanalytics.com/wp-content/uploads/2019/10/install-package.png)
Conclusion
Now, the package is ready to go. Call it from within a python data function in Spotfire as shown below.
![](https://www.bigmountainanalytics.com/wp-content/uploads/2019/10/import-pandas.png)
Spotfire Version
Content created with Spotfire 10.2
Pingback: What is Python_Data_Function? » The Analytics Corner
Pingback: How to Search for DXP Dependencies » The Analytics Corner