我曾尝试在终端使用下面的命令来安装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' –