Hello All,
I am working to pull data from an API using Python in Alteryx. I have copied the JSONRPC package from python on my local computer to the site packages in Alteryx's location "C:\Program Files\Alteryx\bin\Miniconda3\Lib\site-packages". When I try to execute the command "from jsonrpclib import jsonrpc" I get the following error "ImportError: cannot import name 'Transport' "
I am able to run the python script fully in the python application under the Miniconda3 subdirectory, so I am not sure why it will not work in Alteryx designer.
Screenshots below and I blocked off parts of the python code for company privacy.
Thank you,
Zachary Pappas
Solved! Go to Solution.
Typically, the issue is you can not copy a package from one Python installation to another.
I would recommend doing a pip install of the package from the Miniconda3\Scripts subdirectory in Alteryx.
Hey William,
I have removed/uninstalled the packages I copied into Alteryx Site Packages, and then installed them using the following command "Package.installPackages(['jsonrpc','jsonrpclib','impacket','jsonrpc_requests','jsonrpcclient','jsonschema','pprint'])"
When I ran "from jsonrpclib import jsonrpc", I received "No module named 'xmlrpclib'". Xmlrpclibwould not install from packages, so I downloaded it from here (http://effbot.org/downloads/#xmlrpclib) and placed it into the site packages location. When I ran it again, I still get the error "cannot import name 'Transport'
Thank you,
Slowly getting there. I renamed xmlrpclib to xmlrpc.client, then got "No module named 'httplib'. I had to change httplib to http.client. I then got the error "Cannot import name 'HTTP'". I saw the line that had "from httplib import HTTP, HTTPConnection" and I removed "HTTP," and it worked to run the original code "from jsonrpclib import jsonrpc".
Now I am trying to call the host using jsonrpc.ServerProxy("host:port") and I get "Attribute Error module 'urllib' has no attribute 'splittype'". So far, I have tried changing urllib to urllib.request, urllib to urllib3.request, and urllib3, but it still gave me the same error. I also tried to add import urllib.parse and change the splittype line to urllib.parse and no luck.
Thank you for the help!!
And another update. I used a web 2to3 python converter for the jsonrpc file, and added in the line "from urllib.parse import (splittype, splithost)" in the jsonrpc package.
Next, when calling the host, i changed it from "jsonrpc.serverproxy" to "jsonrpc.xmlserverproxy" and that worked. Now i am on the last line to call the API and I get "xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0". I am only setting response equal to the report I am looking for with the proper parameters, so I am trying to figure this out!
After a few issues with Alteryx saying jupyter notebook could not load, re-installs, and a final uninstall and reinstall, I was able to get python working again. I received some tips from stack overflow here
that suggested I use jsonrpclib-pelix instead of jsonrpclib because it was supported on python 2, but not 3. Everything works now!