ImportError: cannot import name request
christianTF opened this issue · comments
Christian Fenzl commented
Hi, sorry if this question is misplaced, or basic python. I've implemented an JsonRpcAPI server (in PHP) for our software, and I'm not familiar with Python yet, and only tried to test the API ;-)
I've tried to install and run the sample, but stuck with `cannot import name request'.
root@loxberry-dev:/tmp# pip install "jsonrpcclient[requests]"
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: jsonrpcclient[requests] in /usr/local/lib/python2.7/dist-packages (2.6.0)
Requirement already satisfied: future==0.16.0 in /usr/local/lib/python2.7/dist-packages (from jsonrpcclient[requests]) (0.16.0)
Requirement already satisfied: click==6.7 in /usr/local/lib/python2.7/dist-packages (from jsonrpcclient[requests]) (6.7)
Requirement already satisfied: jsonschema==2.6.0 in /usr/local/lib/python2.7/dist-packages (from jsonrpcclient[requests]) (2.6.0)
Requirement already satisfied: requests; extra == "requests" in /usr/local/lib/python2.7/dist-packages (from jsonrpcclient[requests]) (2.22.0)
Requirement already satisfied: functools32; python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from jsonschema==2.6.0->jsonrpcclient[requests]) (3.2.3.post2)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python2.7/dist-packages (from requests; extra == "requests"->jsonrpcclient[requests]) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python2.7/dist-packages (from requests; extra == "requests"->jsonrpcclient[requests]) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/dist-packages (from requests; extra == "requests"->jsonrpcclient[requests]) (2019.6.16)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python2.7/dist-packages (from requests; extra == "requests"->jsonrpcclient[requests]) (1.25.3)
root@loxberry-dev:/tmp# python3 jsonrpcclient.py
Traceback (most recent call last):
File "jsonrpcclient.py", line 1, in <module>
from jsonrpcclient import request
File "/tmp/jsonrpcclient.py", line 1, in <module>
from jsonrpcclient import request
ImportError: cannot import name 'request' from 'jsonrpcclient' (/tmp/jsonrpcclient.py)
root@loxberry-dev:/tmp# python2 jsonrpcclient.py
Traceback (most recent call last):
File "jsonrpcclient.py", line 1, in <module>
from jsonrpcclient import request
File "/tmp/jsonrpcclient.py", line 1, in <module>
from jsonrpcclient import request
ImportError: cannot import name request
It's Raspberry Pi 2 with Debian/Raspbian 10 Buster and
- Python 2.7.16
- Python 3.7.3
- pip 19.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
Do you have a solution, or a link with instructions, to repair this?
Thanks a lot!
Christian
Beau commented
Your jsonrpcclient.py is clashing with the jsonrpcclient package. Rename it to something else.