简体   繁体   English

即使使用conda安装后也无法安装tensorflow

[英]can't install tensorflow even after installation with conda

Hello Stackoverflow people. 您好Stackoverflow的人。 Merry Christmas! 圣诞节快乐!

I'm having trouble with installing tensorflow. 我在安装tensorflow时遇到问题。 I'm using window 10 and I installed tensorflow with this code. 我正在使用窗口10,并使用此代码安装了tensorflow。

conda create -n tensorflow python=3.6
activate tensorflow
pip install tensorflow

After finishing all installation, I checked if it's installed successfully at the anaconda prompt 完成所有安装后,我在anaconda提示符下检查是否已成功安装

(tensorflow) > python
>>> import tensorflow as tf
>>> hello = tf.constant("Hello, tensorflow")
>>> sess = tf.Session()
>>> print(sess.run(hello))

It printed out "Hello, tensorflow" very well. 它很好地打印出“ Hello,tensorflow”。 But after that when I tried to import tensorflow or keras on my jupytor notebook or spyder, it threw error. 但是之后,当我尝试在jupytor笔记本或spyder上导入tensorflow或keras时,它抛出了错误。

No module named 'tensorflow'

The version of python is 3.7 so I tried to downgrade it. python的版本是3.7,因此我尝试将其降级。

conda install python=3.6

But still, it doesn't work. 但是,它仍然行不通。 What should I do? 我该怎么办? I just guess downgrading didn't work well, cause I still can see 'Spyder(Python=3.7)' at the right top of the spyder window. 我只是认为降级效果不佳,因为我仍然可以在spyder窗口的右上方看到“ Spyder(Python = 3.7)”。

Please Help! 请帮忙!

I think you just use another version of Python so you can use this command to get the path of tensorflow, for some platform the default pip is for Python2, so maybe you will get: 我认为您只是使用另一个版本的Python,因此可以使用此命令获取tensorflow的路径,对于某些平台,默认pip适用于Python2,因此也许您会得到:

C:\Users\Nick>pip show six
Name: six
Version: 1.11.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: c:\python27\lib\site-packages
Requires:

Also from the doc Work with multiple versions of Python installed in parallel . 同样来自doc 使用并行安装的多个版本的Python

You can try this: 您可以尝试以下方法:

On Linux, Mac OS X, and other POSIX systems, use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip: 在Linux,Mac OS X和其他POSIX系统上,将版本化的Python命令与-m开关结合使用,以运行适当的pip副本:

python2   -m pip install SomePackage  # default Python 2
python2.7 -m pip install SomePackage  # specifically Python 2.7
python3   -m pip install SomePackage  # default Python 3
python3.4 -m pip install SomePackage  # specifically Python 3.4

Appropriately versioned pip commands may also be available. 适当版本的pip命令也可能可用。

On Windows, use the py Python launcher in combination with the -m switch: 在Windows上,将py Python启动器与-m开关结合使用:

py -2   -m pip install SomePackage  # default Python 2
py -2.7 -m pip install SomePackage  # specifically Python 2.7
py -3   -m pip install SomePackage  # default Python 3
py -3.4 -m pip install SomePackage  # specifically Python 3.4

If you have a broken pip on Anaconda, you can follow these steps: 如果您在Anaconda上的pip坏了,可以按照以下步骤操作:

  1. Find pip folder under "../Anaconda3/Lib/site-packages/", delete it manually. 在“ ../Anaconda3/Lib/site-packages/”下找到pip文件夹,手动将其删除。
  2. In Anacoda prompt do : conda uninstall pip 在Anacoda提示符下执行: conda uninstall pip
  3. Install pip using your familiar way. 使用您熟悉的方式安装pip。 Eg: conda install -c anaconda pip 例如: conda install -c anaconda pip

Hope this helps. 希望这可以帮助。

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

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