问题描述:

在安装好了的虚拟环境中查看python、torch、torchvision版本:

(pytorch_env) zq@zq-GI5CN54:~$ python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 12:22:00) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zq/anaconda3/envs/pytorch_env/lib/python3.6/site-packages/torch/__init__.py", line 81, in <module>
    from torch._C import *
ImportError: /home/zq/anaconda3/envs/pytorch_env/lib/python3.6/site-packages/torch/lib/libtorch_python.so: undefined symbol: PySlice_Unpack

原因分析:

pytorch环境中使用的Python版本是3.6.0,这个版本与pytorch1.2.0有冲突,更新一下python的版本就行,整个过程如下。


解决方案:

安装python=3.6.2
在这里插入图片描述问题解决
在这里插入图片描述

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐