我正在使用此代码:
import tensorflow as tf
,它工作正常。
当我现在尝试导入它时,我收到以下错误
In [2]: import tensorflow as tf
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-41389fad42b5> in <module>()
----> 1 import tensorflow as tf
/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py in <module>()
21 from __future__ import print_function
22
---> 23 from tensorflow.python import *
/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py in <module>()
63 from tensorflow.core.util.event_pb2 import *
64 # Import things out of contrib
---> 65 import tensorflow.contrib as contrib
66
67 # Framework
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/__init__.py in <module>()
28 from tensorflow.contrib import grid_rnn
29 from tensorflow.contrib import layers
---> 30 from tensorflow.contrib import learn
31 from tensorflow.contrib import linear_optimizer
32 from tensorflow.contrib import lookup
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/__init__.py in <module>()
70
71 # pylint: disable=wildcard-import
---> 72 from tensorflow.contrib.learn.python.learn import *
73 from tensorflow.python.util.all_util import make_all
74
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/__init__.py in <module>()
21
22 # pylint: disable=wildcard-import
---> 23 from tensorflow.contrib.learn.python.learn import *
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/__init__.py in <module>()
24 # pylint: disable=wildcard-import
25 from tensorflow.contrib.learn.python.learn import datasets
---> 26 from tensorflow.contrib.learn.python.learn import estimators
27 from tensorflow.contrib.learn.python.learn import graph_actions
28 from tensorflow.contrib.learn.python.learn import learn_io as io
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/__init__.py in <module>()
21
22 from tensorflow.contrib.learn.python.learn.estimators._sklearn import NotFittedError
---> 23 from tensorflow.contrib.learn.python.learn.estimators.autoencoder import TensorFlowDNNAutoencoder
24 from tensorflow.contrib.learn.python.learn.estimators.base import TensorFlowBaseTransformer
25 from tensorflow.contrib.learn.python.learn.estimators.base import TensorFlowEstimator
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/autoencoder.py in <module>()
23
24 from tensorflow.contrib.learn.python.learn import models
---> 25 from tensorflow.contrib.learn.python.learn.estimators.base import TensorFlowBaseTransformer
26 from tensorflow.python.ops import nn
27
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/base.py in <module>()
32 from tensorflow.contrib import layers
33 from tensorflow.contrib.learn.python.learn.estimators import _sklearn
---> 34 from tensorflow.contrib.learn.python.learn.estimators import estimator
35 from tensorflow.contrib.learn.python.learn.estimators._sklearn import NotFittedError
36 from tensorflow.contrib.learn.python.learn.learn_io.data_feeder import setup_train_data_feeder
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py in <module>()
37 from tensorflow.contrib.learn.python.learn.estimators import tensor_signature
38 from tensorflow.contrib.learn.python.learn.estimators._sklearn import NotFittedError
---> 39 from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
40 from tensorflow.contrib.learn.python.learn.utils import checkpoints
41
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/learn_io/__init__.py in <module>()
28 from tensorflow.contrib.learn.python.learn.learn_io.graph_io import read_keyed_batch_examples
29 from tensorflow.contrib.learn.python.learn.learn_io.graph_io import read_keyed_batch_features
---> 30 from tensorflow.contrib.learn.python.learn.learn_io.pandas_io import extract_pandas_data
31 from tensorflow.contrib.learn.python.learn.learn_io.pandas_io import extract_pandas_labels
32 from tensorflow.contrib.learn.python.learn.learn_io.pandas_io import extract_pandas_matrix
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/learn_io/pandas_io.py in <module>()
22 try:
23 # pylint: disable=g-import-not-at-top
---> 24 import pandas as pd
25 HAS_PANDAS = True
26 except ImportError:
/usr/local/lib/python2.7/dist-packages/pandas/__init__.py in <module>()
23
24 try:
---> 25 from pandas import hashtable, tslib, lib
26 except ImportError as e: # pragma: no cover
27 module = str(e).lstrip('cannot import name ') # hack but overkill to use re
/home/kv/pandas/src/numpy.pxd in init pandas.hashtable (pandas/hashtable.c:38364)()
ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96
我甚至尝试升级numpy,但这并没有解决问题。 你能帮我解决这个错误吗?
编辑: numpy(1.8.2) 张量流量(0.10.0rc0) python 2.7.6
答案 0 :(得分:1)
您需要更新numpy或重新编译pandas。
这里提供了非常好的答案和解释:ValueError: numpy.dtype has the wrong size, try recompiling
答案 1 :(得分:0)
我强烈建议使用anaconda发行版并使用以下方法安装最新的tensorflow:
session_start();
$aadhar_id=$_POST['aadhar_id'];
if(isset($_POST['submit']))
{
$status=$_POST['status'];
$update=$db->prepare('update aadhar_card set status=:status where aadhar_id=:aadhar_id');
$update->bindValue(':status',$status);
$update->bindValue(':aadhar_id',$aadhar_id);
$update->execute();
if($update)
header('location:formAdmin.php');//it is redirecting but not updating
else
echo 'not happening';
}
?>
<html>
<head></head>
<body>
<form action="" method="post">
<div class="col-md-4 col-md-push-5">
<select class="col-md-5" style="height: 5%;" name="status">
<option value="Accepted" >Accepted</option>
<option value="Pending" >Pending</option>
<option value="Rejected">Rejected</option>
</select>
<input type="submit" value="Update Status" name="submit">
</div>
</form>
</body>
</html>
答案 2 :(得分:0)
尝试使用
在PIP上安装numpysudo apt-get install python-pip
sudo pip install numpy==1.11.1
或pip3而不是pip for python 3 like
sudo apt-get install python3-pip
sudo pip3 install numpy==1.11.1
这会有所帮助,因为我也有这个错误,因为tensorflow正在使用numpy 1.11.1