While working through the first example notebook ('1_Basic_Queries.ipynb'), specifically at the execution of the second code block, an AttributeError is encountered, under a python 3 environment.
Steps to Reproduce
Open the first example notebook.
Execute the second code block:
for lib in Library.search_by_ids([7387,10295,7494,7269]):
print(lib.properties()[['id','pdac','num','elements']])
Observe the AttributeError indicating the absence of the 'urlopen' attribute in the urllib module.
Expected Behavior
The code block should execute without errors, fetching and displaying the properties of the libraries identified by the given IDs.
Actual Behavior
An AttributeError is thrown, specifically stating:
AttributeError: module 'urllib' has no attribute 'urlopen'
This is traced back to the following line in the library.py file:
response = urllib.urlopen(url)
Possible Solution
The error encountered results from attempting to use urllib.urlopen, which is not available in Python 3. In Python 2.x, urllib.urlopen was used to open a network object denoted by a URL for reading. However, this function has been moved to urllib.request.urlopen in Python 3, as discussed in this StackOverflow post. Thus, to successfully run this code block and subsequent ones that requires sample.py, one need to replace all urllib by urllib.request in the library.py and sample.py files.
Description
While working through the first example notebook ('1_Basic_Queries.ipynb'), specifically at the execution of the second code block, an AttributeError is encountered, under a python 3 environment.
Steps to Reproduce
Open the first example notebook.
Execute the second code block:
Observe the AttributeError indicating the absence of the 'urlopen' attribute in the
urllib
module.Expected Behavior
The code block should execute without errors, fetching and displaying the properties of the libraries identified by the given IDs.
Actual Behavior
An AttributeError is thrown, specifically stating:
AttributeError: module 'urllib' has no attribute 'urlopen'
This is traced back to the following line in the
library.py
file:Possible Solution
The error encountered results from attempting to use urllib.urlopen, which is not available in Python 3. In Python 2.x, urllib.urlopen was used to open a network object denoted by a URL for reading. However, this function has been moved to urllib.request.urlopen in Python 3, as discussed in this StackOverflow post. Thus, to successfully run this code block and subsequent ones that requires sample.py, one need to replace all urllib by urllib.request in the library.py and sample.py files.