Python Script - I am using this component in Matillion by writing a python script to call an API and retrieve data. However, I get the error 'ModuleNotFoundError for the line ': No module named 'requests'' while running in Python3.. Any pointers on this?

Python Script - I am using this component in Matillion by writing a python script to call an API and retrieve data. However, I get the error 'ModuleNotFoundError for the line ‘: No module named ‘requests’’ while running in Python3… Any pointers on this?

This means you don't have the Python requests module installed on your Matillion instance. There are a few ways of installing modules but the easiest is to SSH into the Matillion instance and then run "sudo pip install requests". Once you have done this, you will be able to run the Python script that was throwing the error you are getting. I hope this helps.

 

As a way of easing the pain of upgrades, you might want to include the pip installs in the UserData of the instance. If you are on AWS, I would use a Cloudformation template that you are version controlling to keep track of the changes. It will make upgrades much easier in the future. I hope this helps!

Requests is not a built in module (does not come with the default python installation), so you will have to install requests module:

 

Windows

 

Use pip install requests (or pip3 install requests for python3) if you have pip installed and Pip.exe added to the Path Environment Variable. If pip is installed but not in your path you can use python -m pip install requests (or python3 -m pip install requests for python3)

 

Alternatively from a cmd prompt, use > Path\easy_install.exe requests, where Path is your Python*\Scripts folder, if it was installed. (For example: C:\Python32\Scripts)

 

If you manually want to add a library to a windows machine, you can download the compressed library, uncompress it, and then place it into the Lib\site-packages folder of your python path. (For example: C:\Python27\Lib\site-packages)

 

 

Linux

 

For Debian/Ubuntu Python2: sudo apt-get install python-requests

 

For Debian/Ubuntu Python3: sudo apt-get install python3-requests