在PyCharm中使用tensorflow时,我一直收到以下错误:
/home/user/tensorflow/bin/python /home/user/PycharmProjects /TensorPlay/hello.py
Traceback (most recent call last):
File "/home/user/PycharmProjects/TensorPlay/hello.py", line 2, in <module>
import tensorflow as tf
File "/home/user/tensorflow/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/user/tensorflow/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 27, in <module>
import ctypes
File "/usr/lib/python3.5/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: /home/user/tensorflow/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _PyUnicode_AsWideCharString
Process finished with exit code 1
hello.py就是这个简单的示例代码:
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
print(node1, node2)
PyCharm会检测所有Tensorflow元素并自动完成我想要的所有内容。
我还尝试在控制台中运行virtualenv。 任何相关的Python都会导致相同的错误。我尝试用
升级tensorflowsource ~/tensorflow/bin/activate
pip3 install --upgrade tensorflow
并且也有完全相同的错误(而不是hello.py文件pip3中有错误)
有什么建议吗?
编辑: 我想我看到了问题。可能是我的virtualenv想要Python 3.5.3?我最后升级的事情是我的Linux升级到Python 3.5.4如何在不创建新的virtualenv的情况下修复它?我如何确保它在未来的更新中不会发生?
答案 0 :(得分:3)
我只能修复删除旧的virtualenv并设置新的问题。