Python3.6.5在Pentaho8.0中执行requests.get触发RecursionError问题
My Environment
- Server OS: Windows 10
- Standalone Python: 3.6.5
- Requests version: 2.18.4
- Pentaho version: 8.0
The Issue
When I run this simple requests call in my regular Python 3.6.5 command line, it works flawlessly and returns the expected JSON:
>>> import requests >>> response = requests.get(url, headers=headers) >>> json = response.json() >>> print(json) {'d': {'results': [{'_ ...
But when I run the exact same code inside Pentaho 8.0's CPython environment, I get a RecursionError: maximum recursion depth exceeded that traces back to this line in ssl.py:
super(SSLContext, SSLContext).options.__set__(self, value)
Fixes I've Used for Similar Issues
I've tackled Pentaho-Python SSL conflicts before, so here are some actionable steps to try:
Force a custom SSL context in requests
The default SSL context handling in requests might be clashing with whatever Pentaho is using under the hood. Try creating a basic SSL context explicitly and passing it to your request:import requests import ssl from ssl import SSLContext # Create a simple TLS context ctx = SSLContext(ssl.PROTOCOL_TLS) # Optional: Disable strict checks temporarily to test (not for production!) ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE # Pass the context and disable verify to bypass conflicting setup response = requests.get(url, headers=headers, verify=False, ssl_context=ctx) json_data = response.json() print(json_data)Heads up: Turning off certificate verification is a temporary test—make sure to re-enable it in production if this fixes the issue, or find a way to load the correct CA certificates.
Point Pentaho to your standalone Python installation
Pentaho often bundles its own Python runtime, which might be outdated or conflicting with your working 3.6.5 setup. To fix this:- Open
spoon.bat(the file you use to launch Pentaho Spoon) in a text editor - Add these lines at the top to set your Python home as the default:
set PYTHON_HOME=C:\Your\Python36\Installation\Path set PATH=%PYTHON_HOME%;%PATH% - Restart Pentaho and run your script again. This forces Pentaho to use the same Python environment that works in your command line.
- Open
Adjust your Requests version
Requests 2.18.4 might have compatibility issues with the SSL stack that Pentaho uses. Try upgrading to a version that's still compatible with Python 3.6 (like 2.22.0) or downgrading to 2.17.0. You'll need to install it directly into the Python environment that Pentaho uses:pip install requests==2.22.0 --target=C:\Path\To\Pentaho\bundled\Python\Lib\site-packagesMake sure to back up the existing
requestsfolder in that directory before overwriting it, just in case.Increase recursion limit (last-ditch workaround)
If nothing else works, you can temporarily bump up the recursion limit in your script. This doesn't fix the root cause, but might let your code run:import sys # Bump limit from default 1000 to 1500 sys.setrecursionlimit(1500) import requests # Rest of your script goes here...
内容的提问来源于stack exchange,提问作者user3871

