简体   繁体   English

安装tensorflow时出现错误

[英]An error ocurred when installing tensorflow

When I desire to install tensorflow by use the command "pip3 install --upgrade tensorflow", then an error occurred :当我想通过使用命令“pip3 install --upgrade tensorflow”来安装 tensorflow 时,发生了一个错误:

ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\User\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\tensorflow_estimator\\python\\estimator\\canned\\linear_optimizer\\python\\utils\\__pycache__\\sharded_mutable_dense_hashtable.cpython-37.pyc'

How to solve this problem?如何解决这个问题呢? please!请!

I read your question and i want to answer your question is my answer solve your question then i will be really happy with that.我读了你的问题,我想回答你的问题是我的回答解决了你的问题,然后我会很高兴。

Basically this is an environment issue so that's why i give you some information when you installing your tensor flow environment in your system.基本上这是一个环境问题,所以这就是为什么当你在你的系统中安装你的张量流环境时我会给你一些信息。

System requirements系统要求

pip 19.0 or later (requires many Linux 2010 support) Ubuntu 16.04 or later (64-bit) mac OS 10.12.6 (Sierra) or later (64-bit) (no GPU support) Windows 7 or later (64-bit) (Python 3 only) Raspbian 9.0 or later pip 19.0 或更高版本(需要许多 Linux 2010 支持) Ubuntu 16.04 或更高版本(64 位) mac OS 10.12.6 (Sierra) 或更高版本(64 位)(不支持 GPU) Windows 7 或更高版本(64 位)(仅限 Python 3) Raspbian 9.0 或更高版本

Hardware requirements硬件要求

Starting with Tensor Flow 1.6, binaries use AVX instructions which may not run on older CPU.从 Tensor Flow 1.6 开始,二进制文件使用 AVX 指令,这些指令可能无法在较旧的 CPU 上运行。 Read the GPU support guide to set up a CUDA -enabled GPU card on Ubuntu or Windows.阅读 GPU 支持指南,在 Ubuntu 或 Windows 上设置支持 CUDA 的 GPU 卡。

Install the Python development environment on your system Requires Python > 3.4 and pip >= 19.0在您的系统上安装 Python 开发环境需要 Python > 3.4 和 pip >= 19.0

  • python 3 --version蟒蛇 3 --version
  • pip3 --version pip3 --version
  • virtualenv --version If these packages are already installed, skip to the next step. virtualenv --version 如果已经安装了这些包,请跳到下一步。 Otherwise, install Python, the pip package manager, and Virtualenv:否则,安装 Python、pip 包管理器和 Virtualenv:
  • sudo apt update sudo apt 更新
  • sudo apt install python 3-dev python 3-pip sudo apt 安装 python 3-dev python 3-pip
  • sudo pip3 install -U virtualenv # system-wide install sudo pip3 install -U virtualenv # 系统范围安装

Caution: Upgrading the system pip can cause problems If not in a virtual environment, use python 3 -m pip for the commands below.注意:升级系统 pip 可能会导致问题 如果不在虚拟环境中,请使用 python 3 -m pip 执行以下命令。 This ensures that you upgrade and use the Python pip instead of the system pip.这可确保您升级和使用 Python pip 而不是系统 pip。

Create a virtual environment (recommended) Python virtual environments are used to isolate package installation from the system.创建虚拟环境(推荐) Python 虚拟环境用于将包安装与系统隔离。

Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:通过选择一个 Python 解释器并创建一个 ./venv 目录来保存它来创建一个新的虚拟环境:

virtualenv --system-site-packages -p python 3 ./venv Activate the virtual environment using a shell-specific command: source ./venv/bin/activate # sh, bash, ksh, or zsh When virtualenv is active, your shell prompt is prefixed with (venv). virtualenv --system-site-packages -p python 3 ./venv 使用特定于 shell 的命令激活虚拟环境: source ./venv/bin/activate # sh、bash、ksh 或 zsh 当 virtualenv 处于活动状态时,您的 shell prompt 以 (venv) 为前缀。

Install packages within a virtual environment without affecting the host system setup.在虚拟环境中安装软件包而不影响主机系统设置。 Start by upgrading pip: pip install --upgrade pip从升级 pip 开始: pip install --upgrade pip

pip list # show packages installed within the virtual environment pip list # 显示安装在虚拟环境中的包

And to exit virtualenv later: deactivate # don't exit until you're done using Tensor Flow稍后退出 virtualenv:deactivate # 在使用 Tensor Flow 之前不要退出

Install the Tensor Flow pip package Choose one of the following Tensor Flow packages to install from PyPI:安装 Tensor Flow pip 包选择以下 Tensor Flow 包之一从 PyPI 安装:

tensor flow —Latest stable release (2.x) for CPU-only (recommended for beginners).张量流 - 仅适用于 CPU 的最新稳定版本 (2.x)(推荐给初学者)。 tensor flow-GPU —Latest stable release with GPU support (Ubuntu and Windows). tensor flow-GPU —支持 GPU 的最新稳定版本(Ubuntu 和 Windows)。 tf-nightly —Preview build (unstable). tf-nightly — 预览版本(不稳定)。 Ubuntu and Windows include GPU support. Ubuntu 和 Windows 包括 GPU 支持。 tensor flow==1.15 —The final version of Tensor Flow 1.x.张量流==1.15 —张量流1.x的最终版本。

Package dependencies are automatically installed.软件包依赖项会自动安装。 These are listed in the setup.py file under REQUIRED_PACKAGES.这些列在 REQUIRED_PACKAGES 下的 setup.py 文件中。

pip install --upgrade tensor flow pip install --upgrade 张量流

python -c "import tensor flow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))" python -c "将张量流导入为 tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

System requirements系统要求

pip 19.0 or later (requires many Linux 2010 support) Ubuntu 16.04 or later (64-bit) mac OS 10.12.6 (Sierra) or later (64-bit) (no GPU support) Windows 7 or later (64-bit) (Python 3 only) Raspbian 9.0 or later pip 19.0 或更高版本(需要许多 Linux 2010 支持) Ubuntu 16.04 或更高版本(64 位) mac OS 10.12.6 (Sierra) 或更高版本(64 位)(不支持 GPU) Windows 7 或更高版本(64 位)(仅限 Python 3) Raspbian 9.0 或更高版本

Hardware requirements硬件要求

Starting with Tensor Flow 1.6, binaries use AVX instructions which may not run on older CPU.从 Tensor Flow 1.6 开始,二进制文件使用 AVX 指令,这些指令可能无法在较旧的 CPU 上运行。 Read the GPU support guide to set up a CUDA -enabled GPU card on Ubuntu or Windows.阅读 GPU 支持指南,在 Ubuntu 或 Windows 上设置支持 CUDA 的 GPU 卡。

Install the Python development environment on your system Requires Python > 3.4 and pip >= 19.0在您的系统上安装 Python 开发环境需要 Python > 3.4 和 pip >= 19.0

python 3 --version pip3 --version virtualenv --version If these packages are already installed, skip to the next step. python 3 --version pip3 --version virtualenv --version 如果这些包已经安装,请跳到下一步。 Otherwise, install Python, the pip package manager, and Virtualenv: sudo apt update sudo apt install python 3-dev python 3-pip sudo pip3 install -U virtualenv # system-wide install否则,安装 Python、pip 包管理器和 Virtualenv: sudo apt update sudo apt install python 3-dev python 3-pip sudo pip3 install -U virtualenv # system-wide install

Install packages within a virtual environment without affecting the host system setup.在虚拟环境中安装软件包而不影响主机系统设置。 Start by upgrading pip: pip install --upgrade pip从升级 pip 开始: pip install --upgrade pip

Install the Tensor Flow pip package Choose one of the following Tensor Flow packages to install from PyPI:安装 Tensor Flow pip 包选择以下 Tensor Flow 包之一从 PyPI 安装:

tensor flow —Latest stable release (2.x) for CPU-only (recommended for beginners).张量流 - 仅适用于 CPU 的最新稳定版本 (2.x)(推荐给初学者)。 tensor flow-GPU —Latest stable release with GPU support (Ubuntu and Windows). tensor flow-GPU —支持 GPU 的最新稳定版本(Ubuntu 和 Windows)。 tf-nightly —Preview build (unstable). tf-nightly — 预览版本(不稳定)。 Ubuntu and Windows include GPU support. Ubuntu 和 Windows 包括 GPU 支持。 tensor flow==1.15 —The final version of Tensor Flow 1.x.张量流==1.15 —张量流1.x的最终版本。

Package dependencies are automatically installed.软件包依赖项会自动安装。 These are listed in the setup.py file under REQUIRED_PACKAGES.这些列在 REQUIRED_PACKAGES 下的 setup.py 文件中。

pip install --upgrade tensor flow pip install --upgrade 张量流

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

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