python运行时:ModuleNotFoundError: No module named ‘tensorflow‘

https://blog.csdn.net/guangwulv/article/details/109559583

 

TensorFlow报错:
python或者anaconda运行时显示:

一般的解决方案:

pip install --upgrade --ignore-installed tensorflow
1
或者

pip install --user --upgrade --ignore-installed tensorflow
1
在DOS窗口运行结果如下:

输入以下命令也是报错:

pip install --upgrade --ignore-installed tensorflow-gpu
1
pip3 install tensorflow #cpu
1
pip3 install tensorflow-gpu
1

那么------既然找不到TensorFlow的版本,那我们就自行查找,输入:

pip3 search tensorflow
1
会出现一大堆的信息

tensorflow (2.3.1) - TensorFlow is an open source machine learning framework for
everyone.
tensorflow-qndex (0.0.22) - tensorflow-qnd x tensorflow-extenteten
tensorflow-plot (0.3.2) - TensorFlow Plot
tensorflow-addons (0.11.2) - TensorFlow Addons.
tensorflow-estimator (2.3.0) - TensorFlow Estimator.
tensorflow-ops (0.0.0) - tensorflow-ops
mesh-tensorflow (0.1.17) - Mesh TensorFlow
tensorflow-io (0.16.0) - TensorFlow IO
tensorflow-recommenders (0.2.0) - Tensorflow Recommenders, a TensorFlow library for recommender
systems.
tensorflow-datasets (4.1.0) - tensorflow/datasets is a library of datasets ready to use with
TensorFlow.
tensorflow-scientific (0.2.0.dev0) - Scientific modeling in TensorFlow
tensorflow-k8s (0.0.2) - Tensorflow serving extension
emloop-tensorflow (0.6.0) - TensorFlow extension for emloop.
axion-tensorflow (0.0.5) - axion for TensorFlow >=2.2.
daltons-tensorflow (0.0.17) - Daltons Tensorflow bindings
tensorflow-extenteten (0.0.22) - TensorFlow extention library
Tensorflow-ChatBots (0.0.12) - ChatBots supporting TensorFlow
cxflow-tensorflow (0.5.0) - TensorFlow extension for cxflow.
tensorflow-compression (1.3) - Data compression in TensorFlow
syft-tensorflow (0.1.0) - TensorFlow Bindings for PySyft
tensorflow-coder (0.0.2) - TensorFlow Coder (TF-Coder): A Program Synthesis Tool for
TensorFlow
dask-tensorflow (0.0.2) - Interactions between Dask and Tensorflow
tensorflow-tracer (1.1.0) - Runtime Tracing Library for TensorFlow
tensorflow-radam (0.15.0) - RAdam implemented in Keras & TensorFlow
redhat-tensorflow (0.0.0) - A build of TensorFlow by Red Hat
aicoe-tensorflow (0.0.0) - A build of TensorFlow by Red Hat
gmlsnets-tensorflow (0.1) - GMLS-Nets Tensorflow implementation
tensorflow-transform (0.25.0) - A library for data preprocessing with TensorFlow
rh-tensorflow (0.0.0) - A build of TensorFlow by Red Hat
sagemaker-tensorflow (2.3.0.1.0.0) - Amazon Sagemaker specific TensorFlow extensions.
tensorflow-manopt (0.1.0) - A library for manifold-constrained optimization in TensorFlow
tensorflow-qnd (0.1.11) - Quick and Dirty TensorFlow command framework
tensorflow-probability (0.11.1) - Probabilistic modeling and statistical inference in TensorFlow
tensorflow-determinism (0.3.0) - Tracking, debugging, and patching non-determinism in TensorFlow
tensorflow-model (0.1.1) - Command-line tool to inspect TensorFlow models
tensorflow-utils (0.1.0) - Classes and methods to make using TensorFlow easier
tensorflow-ranking (0.3.2) - Pip package setup file for TensorFlow Ranking.
tensorflow-cpu-estimator (1.15.1) - TensorFlow Estimator.
tensorflow-io-nightly (0.17.0.dev20201108041428) - TensorFlow IO
tensorflow-gpu-estimator (2.3.0) - TensorFlow Estimator.
tensorflow-lattice-gpu (0.9.8) - TensorFlow Lattice provides lattice models in TensorFlow
tensorflow-directml (1.15.3.dev200911) - TensorFlow is an open source machine learning framework for
everyone.
tensorflow-aarch64 (1.2) - Tensorflow r1.2 for aarch64[arm64,pine64] CPU only.
tensorflow-gan (2.0.0) - TF-GAN: A Generative Adversarial Networks library for TensorFlow.
tensorflow-tflex (1.13.1rc3) - TensorFlow is an open source machine learning framework for
everyone.
tensorflow-fedora28 (1.9.0rc0) - TensorFlow is an open source machine learning framework for
everyone.
tensorflow-federated (0.17.0) - TensorFlow Federated is an open-source federated learning
framework.
tensorflow-rl (0.2.2) - tensorflow-rl: Modular Deep Reinforcement Learning Framework.
tensorflow-gpu (2.3.1) - TensorFlow is an open source machine learning framework for
everyone.
intel-tensorflow (2.3.0) - TensorFlow is an open source machine learning framework for
everyone.
tensorflow-font2char2word2sent2doc (0.0.12) - TensorFlow implementation of Hierarchical Attention Networks for
Document Classification
tensorflow-template (0.2) - A tensorflow template for quick starting a deep learning project.
tensorflow-rocm (2.3.2) - TensorFlow is an open source machine learning framework for
everyone.
tensorflow-cpu (2.3.1) - TensorFlow is an open source machine learning framework for
everyone.
essentia-tensorflow (2.1b6.dev236) - Library for audio and music analysis, description and synthesis,
with TensorFlow support
tensorflow-quantum (0.4.0) - TensorFlow Quantum is a library for hybrid quantum-classical
machine learning.
tensorflow-encrypted (0.4.0) - Layer on top of TensorFlow for doing machine learning on
encrypted data.
tensorflow-text (2.3.0) - TF.Text is a TensorFlow library of text related ops, modules, and
subgraphs.
silence-tensorflow (1.1.1) - Simple python package to shut up Tensorflow warnings and logs.
tensorflow-cloud (0.1.9) - The TensorFlow Cloud repository provides APIs that will allow to
easily go from debugging and training your Keras and TensorFlow
code in a local environment to distributed training in the cloud.
tensorflow-fewshot (0.0.3) - A Python package for few shot learning training and inference in
computer vision using Tensorflow.
tensorflow-serving-client (1.0.0) - Python client for tensorflow serving
tensorflow-transform-canary (0.9.0) - A library for data preprocessing with TensorFlow
rav-tensorflow-transform (0.7.0.910) - A library for data preprocessing with TensorFlow
tensorflow-serving-api (2.3.0) - TensorFlow Serving Python API.
tensorflow-model-analysis (0.25.0) - A library for analyzing TensorFlow models
tensorflow-onmttok-ops (0.4.0) - OpenNMT Tokenizer as TensorFlow Operations
tensorflow-play (0.0.1) - The lightweight engineering TensorFlow wrapper for AI engineer.
Write less, Reuse more, Scale easily.
tensorflow-hub (0.10.0) - TensorFlow Hub is a library to foster the publication, discovery,
and consumption of reusable parts of machine learning models.
tensorflow-kernels (0.1.2) - A package with Tensorflow (both CPU and GPU) implementation of
most popular Kernels for kernels methods (SVM, MKL...).
tensorflow-graphics (2020.5.20) - A library that contains well defined, reusable and cleanly
written graphics related ops and utility functions for
TensorFlow.
tensorflow-io-2.0-preview (0.7.0.dev1369) - TensorFlow IO
tensorflow-constrained-optimization (0.2) - A library for performing constrained optimization in TensorFlow
ngraph-tensorflow-bridge (0.18.0) - Intel nGraph compiler and runtime for TensorFlow
tensorflow-technical-indicators (0.1.2) - Technical Indicators as TensorFlow Graph Functions
tensorflow-deploy-utils (1.0.0) - Utils for managing and communication with TensorFlow Deploy
intel-tensorflow-avx512 (2.3.0) - TensorFlow is an open source machine learning framework for
everyone.
tensorflow-federated-nightly (0.17.0.dev20201107) - TensorFlow Federated is an open-source federated learning
framework.
tensorflow-rocm-enhanced (2.3.2) - TensorFlow is an open source machine learning framework for
everyone.
simple-tensorflow-serving (0.8.1.1) - The simpler and easy-to-use serving service for TensorFlow models
Tensorflow-Telegram-Bot (0.0.2) - TensorFlow Telegram Bot which can be used as callback
tensorflow-serving-client-grpc (2.3.0) - A prebuilt tensorflow serving client from the tensorflow serving
proto files
neuraxle-tensorflow (0.1.2) - TensorFlow steps, savers, and utilities for Neuraxle. Neuraxle is
a Machine Learning (ML) library for building neat pipelines,
providing the right abstractions to both ease research,
development, and deployment of your ML applications.
attention-tensorflow-mesh (0.0.2) - A bunch of attention related functions, for constructing
transformers in tensorflow mesh
tensorflow-serving-api-gpu (2.3.0) - TensorFlow Serving Python API.
spark-tensorflow-distributor (0.1.0) - This package helps users do distributed training with TensorFlow
on their Spark clusters.
tensorflow-auto-detect (1.11.0) - Automatically install CPU or GPU tensorflow determined by looking
for a CUDA installation.
tensorflow-gcs-config (2.3.0) - TensorFlow operations for configuring access to GCS (Google
Compute Storage) resources.
sagemaker-tensorflow-training (20.1.4) - Open source library for creating TensorFlow containers to run on
Amazon SageMaker.
tensorflow-object-detection-api (0.1.1) - Tensorflow Object Detection Library Packaged
tensorflow-coder-colab-logging (0.0.2) - Logging utilities for TensorFlow Coder's Colab interface
tensorflow-serving-api-python3 (1.8.0) - *UNOFFICIAL* TensorFlow Serving API libraries for Python3
tensorflow-graphics-gpu (1.0.0) - A library that contains well defined, reusable and cleanly
written graphics related ops and utility functions for
TensorFlow.
yifeif-tensorflow-graphics (2020.6.11) - A library that contains well defined, reusable and cleanly
written graphics related ops and utility functions for
TensorFlow.
tensorflow-exercise-hx (1.0.1) - tensorflow练习:鸢尾花&#31181
;类预测,加州房价
预测
tensorflow-enterprise-addons (0.1.1) - Client-side library suite of TensorFlow Enterprise on Google
CloudPlatform (GCP), which implements specific integration
between GCP andTensorFlow APIs.
tensorflow-consciousness (0.1) - Supports a variety of biological learning algorithms.
mlops-tensorflow (0.1.0) -
tensorflow-privacy (0.5.1) -
resnet-tensorflow (0.0.1) - Deep Residual Neural Network

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
查询python 的版本:

>>>C:\Users\pc>python
Python 3.9.0a4 (tags/v3.9.0a4:6e02691, Feb 25 2020, 23:23:54) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
1
2
3
-----------------------------发现问题----------------------
安装不成功的原因是:
1:电脑是32bit的
2:Python版本高于3.6

查询系统版本:

python -v
1
# D:\Python3.9\lib\__pycache__\_sitebuiltins.cpython-39.pyc matches D:\Python3.9\lib\_sitebuiltins.py
# code object from 'D:\\Python3.9\\lib\\__pycache__\\_sitebuiltins.cpython-39.pyc'
import '_sitebuiltins' # <_frozen_importlib_external.SourceFileLoader object at 0x000002885BD175E0>
import 'site' # <_frozen_importlib_external.SourceFileLoader object at 0x000002885BD05280>
Python 3.9.0a4 (tags/v3.9.0a4:6e02691, Feb 25 2020, 23:23:54) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import 'atexit' # <class '_frozen_importlib.BuiltinImporter'>
>>>
1
2
3
4
5
6
7
8
如下图:Python是3.9 环境是64bit

版本高于3.6,打开Anaconda查看其Python版本

安装TensorFlow方法:
CPU版本的安装

pip install --ignore-installed --upgrade tensorflow

安装步骤:
1:TensorFlow在Windows下,支持Python 3.6版本
2:在DOS窗口中输入:[目的:输入清华仓库镜像,加快更新速度]

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
1
3:然后再输入:

conda config --set show_channel_urls yes
1
4:Anaconda3创建一个python3.6的环境,环境名称为tensorflow ,命令如下:

conda create -n tensorflow python=3.6
1
anaconda在这里的意思安装依赖包,所以要下载一会~~~~

 

5:询问是否安装:6:输入

>> y
1
然后开始出现下图的趋势:
-----done-------
此时的Anaconda已经显示在更新新动态
打开Anaconda>>Environments 就可看到TensorFlow的选项:
表示TensorFlow的环境已经建好:

7:在Anaconda的启动TensorFlow:

activate tensorflow
1

8:安装cpu版本的TensorFlow

pip install --upgrade --ignore-installed tensorflow
1
响应结果如下图:

 

当不使用TensorFlow时,可以通过deactivate来关闭TensorFlow环境:

>> deactivate
1
9:测试cpu版本的TensorFlow:
先启动:activate tensorflow
再进入Python:python

文章知识点与官方知识档案匹配,可进一步学习相关知识
————————————————
版权声明:本文为CSDN博主「lenatu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/guangwulv/article/details/109559583

posted @ 2022-05-23 23:37  China Soft  阅读(1751)  评论(0编辑  收藏  举报