我曾嘗試在終端使用下面的命令來安裝PyTorch:錯誤導入PyTorch - Python的
pip install http://download.pytorch.org/whl/torch-0.2.0.post1-cp27-none-macosx_10_7_x86_64.whl
然後我在Python運行下面的代碼:
import torch
torch.__file__
,並出現以下錯誤:
File "/Users/brian/anaconda/lib/python2.7/site-packages/torch/__init__.py", line 48, in <module>
import torch._dl as _dl_flags
AttributeError: 'module' object has no attribute '_dl'
我試圖研究這個問題,但找不到明確的答案。任何幫助,將不勝感激。
編輯: 這些是從嘗試使用下面的命令來重新安裝PyTorch結果:
pip install http://download.pytorch.org/whl/torch-0.2.0.post1-cp27-none-macosx_10_7_x86_64.whl
pip install torchvision
結果:
Requirement already satisfied: pyyaml in ./anaconda/lib/python2.7/site-packages (from torch==0.2.0.post1)
Requirement already satisfied: numpy in ./anaconda/lib/python2.7/site-packages (from torch==0.2.0.post1)
Requirement already satisfied: torchvision in ./anaconda/lib/python2.7/site-packages
Requirement already satisfied: pillow in ./anaconda/lib/python2.7/site-packages (from torchvision)
Requirement already satisfied: torch in ./anaconda/lib/python2.7/site-packages (from torchvision)
Requirement already satisfied: numpy in ./anaconda/lib/python2.7/site-packages (from torchvision)
Requirement already satisfied: six in ./anaconda/lib/python2.7/site-packages (from torchvision)
Requirement already satisfied: olefile in ./anaconda/lib/python2.7/site-packages (from pillow->torchvision)
Requirement already satisfied: pyyaml in ./anaconda/lib/python2.7/site-packages (from torch->torchvision)
EDIT II
下面的命令:
conda install pytorch torchvision cuda80 -c soumith
產生這樣的結果:
Fetching package metadata ...........
PackageNotFoundError: Packages missing in current channels:
- cuda80
We have searched for the packages in the following channels:
- https://conda.anaconda.org/soumith/osx-64
- https://conda.anaconda.org/soumith/noarch
- https://repo.continuum.io/pkgs/free/osx-64
- https://repo.continuum.io/pkgs/free/noarch
- https://repo.continuum.io/pkgs/r/osx-64
- https://repo.continuum.io/pkgs/r/noarch
- https://repo.continuum.io/pkgs/pro/osx-64
- https://repo.continuum.io/pkgs/pro/noarch
似乎安裝沒有做好,或者你錯過一些包。你使用的是哪個Mac OS?我幾天前安裝了它,但我沒有遇到同樣的問題。可以肯定,你是否運行這些命令: pip install http://download.pytorch.org/whl/torch-0.2.0.post1-cp27-none-macosx_10_7_x86_64.whl pip install torchvision 對不對? –
我已經添加了終端響應,在問題中再次這樣做。你碰巧知道終端命令卸載pytorch,我可以試試嗎? –
@BrianPeach看起來你的Mac上安裝了anaconda,請嘗試使用下列選項:'conda install pytorch torchvision cuda80 -c soumith' –