urllib.request module is missing
-
According to the Python 3 libraries documentation I should be able to use a 'urllib.request' object to call an API and get back data. But I am getting an error: module 'urllib' has no attribute 'request'.
The request part of the urllib library is missing. How should I call an API then?
Prior to the 2023 version I was able to use urllib2. My plugin works fine on MAC and PC at earlier versions of the Python implementation.
-
Hello @bee7er,
Welcome to the Plugin Café forum and the Cinema 4D development community, it is great to have you with us!
Getting Started
Before creating your next postings, we would recommend making yourself accustomed with our Forum and Support Guidelines, as they line out details about the Maxon SDK Group support procedures. Of special importance are:
- Support Procedures: Scope of Support: Lines out the things we will do and what we will not do.
- Support Procedures: Confidential Data: Most questions should be accompanied by code but code cannot always be shared publicly. This section explains how to share code confidentially with Maxon.
- Forum Structure and Features: Lines out how the forum works.
- Structure of a Question: Lines out how to ask a good technical question. It is not mandatory to follow this exactly, but you should follow the idea of keeping things short and mentioning your primary question in a clear manner.
About your First Question
I suppose you need to explicitly import the urllib.request module:
import urllib.request
Let me know if you have any further questions.
Cheers,
Ilia -
Hi Ilia
Many thanks for the prompt response and btw you were absolutely right, although I don't know why. Of course, I had already imported urllib, but I did indeed have to import the request module, which is strange as I have numerous instances where I am able to access modules from an imported library.I am happy to follow any guidelines in order to engage with this forum. Please check the links you gave me for the guidelines as the above links access a blank page. I am using Chrome on my MAC laptop.
-
Hey @bee7er,
I am happy to follow any guidelines in order to engage with this forum. Please check the links you gave me for the guidelines as the above links access a blank page. I am using Chrome on my MAC laptop.
Thank you for pointing that out. That had nothing to do with your hardware and everything with the fact that I had to roll back the forum yesterday and forgot to push that tidbit back into place. Fixed.
And these points are more reading suggestions which we post for all new users, and nothing you did wrong.
Cheers,
Ferdinand -
@ferdinand Brilliant, thank you.