簡體   English   中英

pycharm numpy / tensorflow錯誤

[英]pycharm numpy/tensorflow error

我正在pycharm中同時導入tf和np。 TF版本為1.6.0,numpy版本為1.14.1。 我一直遇到這個錯誤。 請幫忙 -

Traceback (most recent call last):
  File "<path>PycharmProjects/testflow/testflow.py", line 1, in <module>
    import numpy as np
  File "<path>PycharmProjects/testflow/venv/lib/python3.5/site-packages/numpy/__init__.py", line 166, in <module>
    from . import random
  File "<path>/PycharmProjects/testflow/venv/lib/python3.5/site-packages/numpy/random/__init__.py", line 99, in <module>
    from .mtrand import *
  File "type.pxd", line 9, in init mtrand
ValueError: builtins.type has the wrong size, try recompiling. Expected 840, got 864

Process finished with exit code 1

代碼很簡單-

import numpy as np
import tensorflow as tf

a = tf.constant([1, 2, 3], name='myname')
print (a)
with tf.Session() as sess:
    print (sess.run(a))

b = np.array([1,2,3])
print (b)

似乎進口商品只是從那個小片段中弄得一團糟。 嘗試如下操作:

import numpy as np
from numpy import random
from numpy.random import mtrand

i = random.rand()   # Can omit the np in np.random()
j = mtrand.bytes(5)     # Can omit the np.random in np.random.mtrand.bytes(5)
print(i)
print(j)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM