ImportError: cannot import name 'download_url_to_file'

Question:

I tried to run a Python script that uses the download_url_to_file method inside the torch hub, but I got the following error:

Traceback (most recent call last):
  File "crop-video.py", line 1, in <module>
    import face_alignment
  File "$PROGRAMS_PATH$PythonPython36libsite-packagesface_alignment-1.3.3-py3.6.eggface_alignment__init__.py", line 7, in <module>
  File "$PROGRAMS_PATH$PythonPython36libsite-packagesface_alignment-1.3.3-py3.6.eggface_alignmentapi.py", line 7, in <module>
  File "$PROGRAMS_PATH$PythonPython36libsite-packagesface_alignment-1.3.3-py3.6.eggface_alignmentutils.py", line 13, in <module>
ImportError: cannot import name 'download_url_to_file'

I am using Python version 3.6.2. I also have the packages installed with the following versions:

certifi (2020.12.5)
chardet (4.0.0)
cycler (0.10.0)
dataclasses (0.8)
decorator (4.4.2)
face-alignment (1.3.3)
future (0.18.2)
idna (2.10)
imageio (2.9.0)
imageio-ffmpeg (0.4.3)
kiwisolver (1.3.1)
llvmlite (0.36.0)
matplotlib (3.3.4)
networkx (2.5)
numba (0.53.0)
numpy (1.19.5)
opencv-python (4.5.1.48)
Pillow (8.1.2)
pip (9.0.1)
pyparsing (2.4.7)
python-dateutil (2.8.1)
PyWavelets (1.1.1)
requests (2.25.1)
rocketchat-API (0.6.9)
scikit-image (0.17.2)
scipy (1.5.4)
setuptools (28.8.0)
six (1.15.0)
tifffile (2020.9.3)
torch (1.0.0)
torchvision (0.2.1)
tqdm (4.24.0)
typing-extensions (3.7.4.3)
unknown (0.0.0)
urllib3 (1.26.4)

The download_url_to_file method does not appear to be found inside the hub file, but I checked the torch hub, and made sure it was defined! How can this error be fixed?

Asked By: AMIR NYN

||

Answers:

Worked in my Pc
use torch == 1.6
enter image description here

Answered By: Prajot Kuvalekar

please make "download_url_to_file" change as "_download_url_to_file";

Answered By: desheng li