0

I'm trying to use plpython3u with postgresql on windows 11, and I want to use the requests library to make http requests.. So I did this test function:

CREATE OR REPLACE FUNCTION teste()
   RETURNS TEXT
AS $$
    import requests
    
    return '10'
$$ LANGUAGE plpython3u;

I can install the plpython3u extension successfully, this function is also created successfully, but when trying to select this function I receive this error:

ERROR: ModuleNotFoundError: No module named 'requests'
  Onde: Traceback (most recent call last):
  PL/Python function "teste", line 2, in <module>
    import requests
função PL/Python "teste"

It's saying that my requests module is not available. postgresql I get this error, can anyone help me with how I can download the requests package to use in my plpython3u function?

I tried running pip3 install requests --force in this path: C:\Program Files\PostgreSQL\15\pgAdmin 4\python

and apparently the requests package was installed, but when trying to run the function I showed above, the same error persists.

for more context: I installed plpython3u using the edb stack builder/language packages (all the correct environment variables are installed, so much so that simple plpython functions run in my database, except the import request)

I ran the pip3.exe install requests command in my directory: C:\edb\languagepack\v4\Python-3.11\Scripts, and I received an error

Falha na execução do programa 'pip3.exe': O executável especificado não é um aplicativo válido para esta plataforma de

SO.No linha:1 caractere:1

  • pip3 install requests

No linha:1 caractere:1

  • pip3 install requests
  •   + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
      + FullyQualifiedErrorId : NativeCommandFailed
    
    
    

Furthermore, I still cannot use the requests package in my plpython3u function because the error already mentioned at the beginning of the question occurs

6
  • Have you pip installed requests to the Python environment you are working in? In other words can you open the python or ipython CLI(outside Postgres) and import requests? Commented Jan 9, 2024 at 16:17
  • @AdrianKlaver I can run the command pip3 install requests, and pip installs the request but it still generates the error Commented Jan 9, 2024 at 17:44
  • Yes but did you install it in the environment that the version of Python you are linked to in plpython3u is running in? Commented Jan 9, 2024 at 17:51
  • @AdrianKlaver yes, I did what you mentioned.. but nothing yet Commented Jan 9, 2024 at 18:15
  • Did what? Unless you provide an update to your question with details on your setup and a step by step account of what you did there is no way to provide an answer. Commented Jan 9, 2024 at 18:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.