aedocw / epub2tts

Turn an epub or text file into an audiobook
Apache License 2.0
426 stars 43 forks source link

"Unable to import torch" error on Windows #218

Closed alexnev closed 2 months ago

alexnev commented 3 months ago

I've installed torch but it still gives the same error, i dont know what to do, please help. I'm on Windows 10

(.venv) PS C:\epub2TTS\epub2tts> pip install .
Processing c:\epub2tts\epub2tts
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting beautifulsoup4 (from epub2tts==2.3.15)
  Using cached beautifulsoup4-4.12.3-py3-none-any.whl.metadata (3.8 kB)
Collecting deepspeed (from epub2tts==2.3.15)
  Using cached deepspeed-0.14.0.tar.gz (1.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      [WARNING] Unable to import torch, pre-compiling ops will be disabled. Please visit https://pytorch.org/ to see how to properly install torch on your system.
       [WARNING]  unable to import torch, please install it if you want to pre-compile any deepspeed ops.
      DS_BUILD_OPS=1
      Traceback (most recent call last):
        File "C:\epub2TTS\epub2tts\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\epub2TTS\epub2tts\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\epub2TTS\epub2tts\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\D\AppData\Local\Temp\pip-build-env-wgt952dy\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\D\AppData\Local\Temp\pip-build-env-wgt952dy\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "C:\Users\D\AppData\Local\Temp\pip-build-env-wgt952dy\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "C:\Users\D\AppData\Local\Temp\pip-build-env-wgt952dy\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 148, in <module>
      AssertionError: Unable to pre-compile ops without torch installed. Please install torch before attempting to pre-compile ops.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
aedocw commented 3 months ago

Could you try pip install torch==2.1.1 in that same virtual env and see what you get?

I should lock down the versions of all the dependencies, I'd like to do that with pipenv but I haven't had time to get to that. Wondering if there's a newer release of torch that is causing some dependency problems... If the torch installed pinned to 2.1.1 works but you hit other issues, at least it can help point us in the right direction.

alexnev commented 3 months ago

Same error still persists after trying to install 2.1.1

`(.venv) PS C:\epub2TTS\epub2tts> pip install torch==2.1.1
Collecting torch==2.1.1
  Downloading torch-2.1.1-cp311-cp311-win_amd64.whl.metadata (26 kB)
Requirement already satisfied: filelock in c:\epub2tts\epub2tts\.venv\lib\site-packages (from torch==2.1.1) (3.9.0)
Requirement already satisfied: typing-extensions in c:\epub2tts\epub2tts\.venv\lib\site-packages (from torch==2.1.1) (4.8.0)
Requirement already satisfied: sympy in c:\epub2tts\epub2tts\.venv\lib\site-packages (from torch==2.1.1) (1.12)
Requirement already satisfied: networkx in c:\epub2tts\epub2tts\.venv\lib\site-packages (from torch==2.1.1) (3.2.1)
Requirement already satisfied: jinja2 in c:\epub2tts\epub2tts\.venv\lib\site-packages (from torch==2.1.1) (3.1.2)
Requirement already satisfied: fsspec in c:\epub2tts\epub2tts\.venv\lib\site-packages (from torch==2.1.1) (2023.4.0)
Requirement already satisfied: MarkupSafe>=2.0 in c:\epub2tts\epub2tts\.venv\lib\site-packages (from jinja2->torch==2.1.1) (2.1.3)
Requirement already satisfied: mpmath>=0.19 in c:\epub2tts\epub2tts\.venv\lib\site-packages (from sympy->torch==2.1.1) (1.3.0)
Downloading torch-2.1.1-cp311-cp311-win_amd64.whl (192.3 MB)
   ---------------------------------------- 192.3/192.3 MB 21.1 MB/s eta 0:00:00
Installing collected packages: torch
  Attempting uninstall: torch
    Found existing installation: torch 2.2.1+cu121
    Uninstalling torch-2.2.1+cu121:
      Successfully uninstalled torch-2.2.1+cu121
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchaudio 2.2.1+cu121 requires torch==2.2.1+cu121, but you have torch 2.1.1 which is incompatible.
torchvision 0.17.1+cu121 requires torch==2.2.1+cu121, but you have torch 2.1.1 which is incompatible.
Successfully installed torch-2.1.1`
aedocw commented 3 months ago

Could you try editing requirements.txt and removing the "deepspeed" line? I tried on windows 11 and that was what was causing the problem. I am not sure why deepspeed won't install, maybe someone else who is running this on windows can chime in on that. But without deepspeed, the install went great for me, let me know if it works for you.

EDIT - actually pip install . worked great but epub2tts doesn't run (I get a "ImportError: cannot import name 'etree' from 'lxml'" error). I'll poke at it a little bit to see if I can figure out what's going on. If you are able to run wsl and install it under that though, it will probably work out better for you.

aedocw commented 2 months ago

Closing due to lack of response. If other people are hitting the same error on windows please mention it here and I'll re-open, and try running on windows.

oldmanjk commented 1 month ago

pip install . --no-build-isolation works for me @aedocw

Edit - well...it fixed that error anyway