简体   繁体   English

Pip安装Keras和TensorFlow缺少软件包?

[英]Pip Install Keras and TensorFlow missing packages?

I used pip to install keras and tensorflow, yet when I import subpackages from keras, my shell fails a check for PyBfloat16_Type.tp_base. 我使用pip安装keras和tensorflow,但是当我从keras导入子软件包时,我的shell无法通过PyBfloat16_Type.tp_base检查。

I tried uninstalling and reinstalling tensorflow, but I don't know for certain what is causing this error. 我尝试卸载并重新安装tensorflow,但是我不确定是什么原因导致此错误。

from keras.models import Sequential
from keras.layers import Dense
3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
Python Type "help", "copyright", "credits" or "license" for more information.
>>>[evaluate machineLearning.py]
Using TensorFlow backend. 2019-04-21 00:31:22.995541: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr 
aborted (disconnected)
>>>

Can someone help me solve this issue? 有人可以帮我解决这个问题吗?

You may try to downgrade python to 3.6 (I know some people have troubles with tensorflow and keras using python 3.7). 您可以尝试将python降级到3.6(我知道有些人在使用python 3.7时对tensorflow和keras有麻烦)。 One simple way is to download anaconda, create a new environment with python 3.6, then install tensorflow and keras. 一种简单的方法是下载anaconda,使用python 3.6创建一个新环境,然后安装tensorflow和keras。

conda create -n myenv python=3.6

conda activate myenv

pip3 install tensorflow

pip3 install keras

You have a few options to try: 您可以尝试以下几种方法:

First, try to uninstall and re-install the TensorFlow and see whether the problem is resolved or not (replace tensorflow with tensorflow-gpu in the following commands if you have installed the GPU version): 首先,尝试卸载并重新安装TensorFlow,然后查看问题是否得到解决(如果已安装GPU版本,请在以下命令中用tensorflow-gpu替换tensorflow ):

pip uninstall tensorflow 

pip install --no-cache-dir tensorflow

If the problem is not resolved, try to do the same thing with numpy : 如果问题仍未解决,请尝试使用numpy执行相同的操作:

pip uninstall numpy

pip install --no-cache-dir numpy

Hopefully, one of these two would resolve the problem. 希望这两个之一可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM