Running squad_to_dpr.py
causes an error AttributeError: partially initialized module 'requests' has no attribute 'Response' (most likely due to a circular import)
#4880
Labels
Contributions wanted!
Looking for external contributions
I am trying to run the command:
python /home/my_user/.conda/envs/conda_env_py39/bin/python3/site-packages/haystack/utils/squad_to_dpr.py --squad_input_filename "path_to_my_input_data" --dpr_output_filename "path_where_data_would_be_saved"
in order to convert the format of my data into the format which is required by DPR. Unfortunately, I am getting the following error message:
When I run the command
print(sys.modules["haystack.utils.requests"])
, I get as output:<module 'haystack.utils.requests' from '/home/my_user/.conda/envs/conda_env_py39/lib/python3.9/site-packages/haystack/utils/requests.py'>
When I run the command
print(sys.modules["requests.models"])
, I get as output:<module 'requests.models' from '/home/my_user/.conda/envs/conda_env_py39/lib/python3.9/site-packages/requests/models.py'>
I think that the problem is caused by the fact that inside the module
haystack/utils/requests.py
there is an import-statement, theimport requests
statement which should be importing a totally different package that is also calledrequests
, but it imports itself (if that is even possible). The reason why I think that this is the case is because the packagerequests
has a module calledmodels.py
, and inrequests/models.py
(which you can find on the following link: https://github.com/psf/requests/blob/ec78348c4b6292b1a38008fa31e51f7b6b2252dc/requests/models.py#L641) theResponse
class is implemented (which is mentioned in the error message).Probably a very important piece of information is that when I display the content of
sys.path
, I get the following output:I guess that the executed import-statement (i.e. the line
import requests
from modulehaystack/utils/requests.py
) looks first at the current directory and tries to import itself, rather than importing packagerequests
fromsite-packages
.I would really appreciate your help with this matter, as I have no clue what else to try.
Additional information:
haystack
package using shell-commandpip install haystack[all]
, which installed the version1.16.1
for meconda
virtual environment (calledconda_env_py39
)The text was updated successfully, but these errors were encountered: