IT

토치 설치 중 에러

달남 2024. 10. 23. 07:41

프로그램 실행 시 아래와 같이 에러가 난다
ModuleNotFoundError: No module named 'torch'


C:\>pip install touch
WARNING: Ignoring invalid distribution ~ip (C:\Python312\Lib\site-packages)
Collecting touch
  Using cached touch-2020.12.3-py3-none-any.whl
Collecting values (from touch)
  Using cached values-66.0.3.tar.gz (1.2 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: values
  Building wheel for values (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [49 lines of output]
      C:\Python312\Lib\site-packages\setuptools\_distutils\dist.py:261: UserWarning: Unknown distribution option: 'readme'
        warnings.warn(msg)
      running bdist_wheel
      running build
      C:\Python312\Lib\site-packages\setuptools\_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
      !!

              ********************************************************************************
              Please avoid running ``setup.py`` directly.
              Instead, use pypa/build, pypa/installer or other
              standards-based tools.

              See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
              ********************************************************************************

      !!
        self.initialize_options()
      installing to build\bdist.win-amd64\wheel
      running install


해결법
이것저것 다 해봤는데 안되다가 아래의 방법으로 해결 되었다

1.아나콘다 설치

https://www.anaconda.com/download

Download Anaconda Distribution | Anaconda

Download Anaconda's open-source Distribution today. Discover the easiest way to perform Python/R data science and machine learning on a single machine.

www.anaconda.com

이메일 주소 넣으면 이메일이 온다. 클릭후 다운로드 페이지로 이동된다

2. 토치 설치
https://pytorch.org/

PyTorch

pytorch.org


위와 같이 선택 사양을 고르고 나면

run command 가 결정된다. 아래와 같이 결정 되었다

pip3 install torch torchvision torchaudio

아나콘다를 실행하고 위 명령어를 넣으면 설치가 된다

드디어 에러가 해결 되고 실행 되었다 !!!