解決Tensorflow安裝成功,但在導(dǎo)入時(shí)報(bào)錯(cuò)的問(wèn)題
在Mac上按照官網(wǎng)教程安裝成功tensor flow后,但在程序中導(dǎo)入時(shí),仍然報(bào)錯(cuò),包括但不限于以下兩個(gè)錯(cuò)誤。對(duì)于這種錯(cuò)誤,原因主要在于Mac內(nèi)默認(rèn)的python庫(kù)比較老了,即便通過(guò)pip命令安裝了新的包,python也會(huì)默認(rèn)導(dǎo)入默認(rèn)位置的包。這時(shí)候需要做的就是刪除,有沖突的包,對(duì)于以下兩個(gè)錯(cuò)誤,就是分別時(shí)numpy和six兩個(gè)包沖突了。
可以在python命令行環(huán)境下,通過(guò)numpy.version和six.version兩個(gè)命令查看當(dāng)前版本,如果與預(yù)期的不一致,就可以刪掉。
可以通過(guò)numpy.path查看默認(rèn)包的位置。
刪掉即可
import tensorflow
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9 Traceback (most recent call last): File “”, line 1, in File “/Library/Python/2.7/site-packages/tensorflow/init.py”, line 24, in from tensorflow.python import * File “/Library/Python/2.7/site-packages/tensorflow/python/init.py”, line 49, in from tensorflow.python import pywrap_tensorflow File “/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py”, line 52, in raise ImportError(msg) ImportError: Traceback (most recent call last): File “/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py”, line 41, in from tensorflow.python.pywrap_tensorflow_internal import * File “/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”, line 28, in _pywrap_tensorflow_internal = swig_import_helper() File “/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”, line 24, in swig_import_helper _mod = imp.load_module(‘_pywrap_tensorflow_internal', fp, pathname, description) ImportError: numpy.core.multiarray failed to import Failed to load the native TensorFlow runtime. See https://www.tensorflow.org/install/install_sources#common_installation_problems for some common reasons and solutions. Include the entire stack trace above this error message when asking for help. Traceback (most recent call last): File “”, line 1, in File “/Library/Python/2.7/site-packages/tensorflow/init.py”, line 24, in from tensorflow.python import * File “/Library/Python/2.7/site-packages/tensorflow/python/init.py”, line 104, in from tensorflow.python.platform import test File “/Library/Python/2.7/site-packages/tensorflow/python/platform/test.py”, line 41, in from tensorflow.python.framework import test_util as _test_util File “/Library/Python/2.7/site-packages/tensorflow/python/framework/test_util.py”, line 54, in from tensorflow.python.platform import googletest File “/Library/Python/2.7/site-packages/tensorflow/python/platform/googletest.py”, line 35, in from tensorflow.python.platform import benchmark File “/Library/Python/2.7/site-packages/tensorflow/python/platform/benchmark.py”, line 120, in class Benchmark(six.with_metaclass(_BenchmarkRegistrar, object)): File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py”, line 566, in with_metaclass return meta(“NewBase”, bases, {}) File “/Library/Python/2.7/site-packages/tensorflow/python/platform/benchmark.py”, line 115, in new if not newclass.is_abstract(): AttributeError: type object ‘NewBase' has no attribute ‘is_abstract' import tensorflow Traceback (most recent call last): File “”, line 1, in File “/Library/Python/2.7/site-packages/tensorflow/init.py”, line 24, in from tensorflow.python import * File “/Library/Python/2.7/site-packages/tensorflow/python/init.py”, line 49, in from tensorflow.python import pywrap_tensorflow ImportError: cannot import name pywrap_tensorflow
以上這篇解決Tensorflow安裝成功,但在導(dǎo)入時(shí)報(bào)錯(cuò)的問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
pygame編寫(xiě)音樂(lè)播放器的實(shí)現(xiàn)代碼示例
這篇文章主要介紹了pygame編寫(xiě)音樂(lè)播放器的實(shí)現(xiàn)代碼示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11Django學(xué)習(xí)教程之靜態(tài)文件的調(diào)用詳解
這篇文章主要給大家介紹了關(guān)于Django學(xué)習(xí)教程之靜態(tài)文件調(diào)用的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用django具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-05-05如何解決安裝包過(guò)程中的Requirement already satisfied:問(wèn)題
這篇文章主要介紹了如何解決安裝包過(guò)程中的Requirement already satisfied:問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-118個(gè)python新手入門(mén)項(xiàng)目
文將介紹8個(gè)帶有代碼的Python項(xiàng)目,這些項(xiàng)目將幫助大家增強(qiáng)編程能力,這些項(xiàng)目涵蓋了各種主題和難度級(jí)別,助力大家成長(zhǎng)為一個(gè)Python開(kāi)發(fā)者2024-01-01python中使用 unittest.TestCase單元測(cè)試的用例詳解
python 在unittest.TestCase 中提高了很多斷言方法,這篇文章主要介紹了python中使用 unittest.TestCase 進(jìn)行單元測(cè)試的操作方法,需要的朋友可以參考下2021-08-08關(guān)于Pycharm配置翻譯插件Translation報(bào)錯(cuò)更新TTK失敗不能使用的問(wèn)題
這篇文章主要介紹了關(guān)于Pycharm配置翻譯插件Translation報(bào)錯(cuò)更新TTK失敗不能使用的問(wèn)題,本文通過(guò)圖文并茂的形式給大家分享解決方案,需要的朋友可以參考下2022-04-04Appium+python自動(dòng)化怎么查看程序所占端口號(hào)和IP
這篇文章主要介紹了Appium+python自動(dòng)化怎么查看程序所占端口號(hào)和IP,本文以FQ工具 Lantern 為例,通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),需要的朋友可以參考下2019-06-06使用C語(yǔ)言來(lái)擴(kuò)展Python程序和Zope服務(wù)器的教程
這篇文章主要介紹了使用C語(yǔ)言來(lái)擴(kuò)展Python程序和Zope服務(wù)器的教程,本文來(lái)自于IBM官方網(wǎng)站技術(shù)文檔,需要的朋友可以參考下2015-04-04