gpt4 book ai didi

python - 无法在 R 中安装 Tensorflow, "could not find a Python environment for {PATH}"

转载 作者:行者123 更新时间:2023-12-02 16:20:51 34 4
gpt4 key购买 nike

我正在尝试将 Tensorflow 的 R GPU 加速安装到我的 PC 上。我曾经使用过 Python 的英特尔发行版,其中包括常用的科学库,但我从未真正使用过它,因为我是 R 用户,但它以某种方式永久地破坏了我的计算机拥有 Python 功能副本的能力,因为出于某种原因我不能正确安装库。我现在在我的 PC 上安装了 Python,但我不确定它是否有效,因为这是我重新安装它的百万分之一。

除此之外,我正在尝试为 R 安装 Keras,但遇到了一些问题。

当我运行时:

> library(tensorflow)
> install_tensorflow(version = "gpu")

我收到以下错误:

Error: could not find a Python environment for C:\Users\{my name}\AppData\Local\Programs\Python\Python39\python.exe

我检查了那个目录,python.exe 确实存在,所以我不确定是什么问题。我担心我以某种方式随意破坏了一些低级文件,从而阻止我在安装 Windows 时再次使用 Python。卸载并重新安装 Python 无效。

你有什么建议吗?

编辑:在用户安装页面之后:

> library(tensorflow)
> tf$constant("Hellow Tensorflow")
Error: Python module tensorflow was not found.

Detected Python configuration:

python: C:/Users/artas/AppData/Local/Programs/Python/Python39/python.exe
libpython: C:/Users/artas/AppData/Local/Programs/Python/Python39/python39.dll
pythonhome: C:/Users/artas/AppData/Local/Programs/Python/Python39
version: 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
Architecture: 64bit
numpy: [NOT FOUND]
tensorflow: [NOT FOUND]

NOTE: Python version was forced by use_python function

编辑 2:我听从了@jwarz 的建议,但现在我得到了这个错误:

> tensorflow::install_tensorflow(version = "gpu")
Error: .onLoad failed in loadNamespace() for 'tensorflow', details:
call: py_module_import(module, convert = convert)
error: ModuleNotFoundError: No module named 'tensorflow'

Detailed traceback:
File "C:\Users\artas\Documents\R\win-library\4.0\reticulate\python\rpytools\loader.py", line 19, in _import_hook
module = _import(
File "C:\Users\artas\Documents\R\win-library\4.0\reticulate\python\rpytools\loader.py", line 19, in _import_hook
module = _import(

我采取了将 Keras 安装到 conda 环境中的额外步骤。


> reticulate::conda_install(packages = "tensorflow")
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

environment location: C:\Users\artas\MINICO~1\envs\r-reticulate

added / updated specs:
- python
- tensorflow


The following packages will be downloaded:

package | build
---------------------------|-----------------
absl-py-0.11.0 | py37h03978a9_0 169 KB conda-forge
astor-0.8.1 | pyh9f0ad1d_0 25 KB conda-forge
ca-certificates-2020.12.5 | h5b45459_0 173 KB conda-forge
cached-property-1.5.1 | py_0 10 KB conda-forge
certifi-2020.12.5 | py37h03978a9_0 143 KB conda-forge
gast-0.4.0 | pyh9f0ad1d_0 12 KB conda-forge
google-pasta-0.2.0 | pyh8c360ce_0 42 KB conda-forge
grpcio-1.34.0 | py37h04d2302_0 1.8 MB conda-forge
h5py-3.1.0 |nompi_py37h19fda09_100 1009 KB conda-forge
hdf5-1.10.6 |nompi_he0bbb20_101 19.4 MB conda-forge
importlib-metadata-3.3.0 | py37h03978a9_2 21 KB conda-forge
intel-openmp-2020.3 | h57928b3_311 2.0 MB conda-forge
keras-applications-1.0.8 | py_1 30 KB conda-forge
keras-preprocessing-1.1.0 | py_0 33 KB conda-forge
libblas-3.9.0 | 5_mkl 3.9 MB conda-forge
libcblas-3.9.0 | 5_mkl 3.9 MB conda-forge
liblapack-3.9.0 | 5_mkl 3.9 MB conda-forge
libprotobuf-3.14.0 | h7755175_0 2.3 MB conda-forge
m2w64-gcc-libgfortran-5.3.0| 6 342 KB conda-forge
m2w64-gcc-libs-5.3.0 | 7 520 KB conda-forge
m2w64-gcc-libs-core-5.3.0 | 7 214 KB conda-forge
m2w64-gmp-6.1.0 | 2 726 KB conda-forge
m2w64-libwinpthread-git-5.0.0.4634.697f757| 2 31 KB conda-forge
markdown-3.3.3 | pyh9f0ad1d_0 66 KB conda-forge
mkl-2020.4 | hb70f87d_311 172.4 MB conda-forge
msys2-conda-epoch-20160418 | 1 3 KB conda-forge
numpy-1.19.4 | py37hd20adf4_1 4.8 MB conda-forge
openssl-1.1.1i | h8ffe710_0 5.8 MB conda-forge
protobuf-3.14.0 | py37hf2a7229_0 261 KB conda-forge
pyreadline-2.1 |py37hc8dfbb8_1002 146 KB conda-forge
python-3.7.9 |h7840368_0_cpython 17.9 MB conda-forge
python_abi-3.7 | 1_cp37m 4 KB conda-forge
scipy-1.6.0 | py37h6db1a17_0 23.2 MB conda-forge
setuptools-49.6.0 | py37hf50a25e_2 919 KB conda-forge
six-1.15.0 | pyh9f0ad1d_0 14 KB conda-forge
tensorboard-1.14.0 | py37_0 3.2 MB conda-forge
tensorflow-1.14.0 | h1f41ff6_0 23 KB conda-forge
tensorflow-base-1.14.0 | py37hc8dfbb8_0 57.3 MB conda-forge
tensorflow-estimator-1.14.0| py37h5ca1d4c_0 646 KB conda-forge
termcolor-1.1.0 | py_2 6 KB conda-forge
typing_extensions-3.7.4.3 | py_0 25 KB conda-forge
werkzeug-1.0.1 | pyh9f0ad1d_0 239 KB conda-forge
wincertstore-0.2 |py37hc8dfbb8_1005 15 KB conda-forge
wrapt-1.12.1 | py37hcc03f2d_2 46 KB conda-forge
zipp-3.4.0 | py_0 11 KB conda-forge
zlib-1.2.11.1 | vc14ha0a531f_3 378 KB intel
------------------------------------------------------------
Total: 327.8 MB

The following NEW packages will be INSTALLED:

absl-py conda-forge/win-64::absl-py-0.11.0-py37h03978a9_0
astor conda-forge/noarch::astor-0.8.1-pyh9f0ad1d_0
ca-certificates conda-forge/win-64::ca-certificates-2020.12.5-h5b45459_0
cached-property conda-forge/noarch::cached-property-1.5.1-py_0
gast conda-forge/noarch::gast-0.4.0-pyh9f0ad1d_0
google-pasta conda-forge/noarch::google-pasta-0.2.0-pyh8c360ce_0
grpcio conda-forge/win-64::grpcio-1.34.0-py37h04d2302_0
h5py conda-forge/win-64::h5py-3.1.0-nompi_py37h19fda09_100
hdf5 conda-forge/win-64::hdf5-1.10.6-nompi_he0bbb20_101
importlib-metadata conda-forge/win-64::importlib-metadata-3.3.0-py37h03978a9_2
intel-openmp conda-forge/win-64::intel-openmp-2020.3-h57928b3_311
keras-applications conda-forge/noarch::keras-applications-1.0.8-py_1
keras-preprocessi~ conda-forge/noarch::keras-preprocessing-1.1.0-py_0
libblas conda-forge/win-64::libblas-3.9.0-5_mkl
libcblas conda-forge/win-64::libcblas-3.9.0-5_mkl
liblapack conda-forge/win-64::liblapack-3.9.0-5_mkl
libprotobuf conda-forge/win-64::libprotobuf-3.14.0-h7755175_0
m2w64-gcc-libgfor~ conda-forge/win-64::m2w64-gcc-libgfortran-5.3.0-6
m2w64-gcc-libs conda-forge/win-64::m2w64-gcc-libs-5.3.0-7
m2w64-gcc-libs-co~ conda-forge/win-64::m2w64-gcc-libs-core-5.3.0-7
m2w64-gmp conda-forge/win-64::m2w64-gmp-6.1.0-2
m2w64-libwinpthre~ conda-forge/win-64::m2w64-libwinpthread-git-5.0.0.4634.697f757-2
markdown conda-forge/noarch::markdown-3.3.3-pyh9f0ad1d_0
mkl conda-forge/win-64::mkl-2020.4-hb70f87d_311
msys2-conda-epoch conda-forge/win-64::msys2-conda-epoch-20160418-1
numpy conda-forge/win-64::numpy-1.19.4-py37hd20adf4_1
protobuf conda-forge/win-64::protobuf-3.14.0-py37hf2a7229_0
pyreadline conda-forge/win-64::pyreadline-2.1-py37hc8dfbb8_1002
scipy conda-forge/win-64::scipy-1.6.0-py37h6db1a17_0
six conda-forge/noarch::six-1.15.0-pyh9f0ad1d_0
tensorboard conda-forge/win-64::tensorboard-1.14.0-py37_0
tensorflow conda-forge/win-64::tensorflow-1.14.0-h1f41ff6_0
tensorflow-base conda-forge/win-64::tensorflow-base-1.14.0-py37hc8dfbb8_0
tensorflow-estima~ conda-forge/win-64::tensorflow-estimator-1.14.0-py37h5ca1d4c_0
termcolor conda-forge/noarch::termcolor-1.1.0-py_2
typing_extensions conda-forge/noarch::typing_extensions-3.7.4.3-py_0
werkzeug conda-forge/noarch::werkzeug-1.0.1-pyh9f0ad1d_0
wrapt conda-forge/win-64::wrapt-1.12.1-py37hcc03f2d_2
zipp conda-forge/noarch::zipp-3.4.0-py_0
zlib intel/win-64::zlib-1.2.11.1-vc14ha0a531f_3

The following packages will be UPDATED:

openssl intel::openssl-1.1.1h-vc14he774522_0 --> conda-forge::openssl-1.1.1i-h8ffe710_0

The following packages will be DOWNGRADED:

certifi 2020.12.5-py39hcbf5309_0 --> 2020.12.5-py37h03978a9_0
python 3.9.1-h7840368_1_cpython --> 3.7.9-h7840368_0_cpython
python_abi 3.9-1_cp39 --> 3.7-1_cp37m
setuptools 49.6.0-py39h467e6f4_2 --> 49.6.0-py37hf50a25e_2
wincertstore 0.2-py39hde42818_1005 --> 0.2-py37hc8dfbb8_1005



Downloading and Extracting Packages
liblapack-3.9.0 | 3.9 MB | ########## | 100%
m2w64-gcc-libs-core- | 214 KB | ########## | 100%
typing_extensions-3. | 25 KB | ########## | 100%
six-1.15.0 | 14 KB | ########## | 100%
zipp-3.4.0 | 11 KB | ########## | 100%
gast-0.4.0 | 12 KB | ########## | 100%
openssl-1.1.1i | 5.8 MB | ########## | 100%
importlib-metadata-3 | 21 KB | ########## | 100%
grpcio-1.34.0 | 1.8 MB | ########## | 100%
absl-py-0.11.0 | 169 KB | ########## | 100%
ca-certificates-2020 | 173 KB | ########## | 100%
tensorflow-1.14.0 | 23 KB | ########## | 100%
tensorflow-estimator | 646 KB | ########## | 100%
intel-openmp-2020.3 | 2.0 MB | ########## | 100%
m2w64-libwinpthread- | 31 KB | ########## | 100%
werkzeug-1.0.1 | 239 KB | ########## | 100%
libcblas-3.9.0 | 3.9 MB | ########## | 100%
h5py-3.1.0 | 1009 KB | ########## | 100%
keras-applications-1 | 30 KB | ########## | 100%
hdf5-1.10.6 | 19.4 MB | ########## | 100%
wincertstore-0.2 | 15 KB | ########## | 100%
msys2-conda-epoch-20 | 3 KB | ########## | 100%
astor-0.8.1 | 25 KB | ########## | 100%
tensorflow-base-1.14 | 57.3 MB | ########## | 100%
python-3.7.9 | 17.9 MB | ########## | 100%
python_abi-3.7 | 4 KB | ########## | 100%
m2w64-gcc-libgfortra | 342 KB | ########## | 100%
tensorboard-1.14.0 | 3.2 MB | ########## | 100%
numpy-1.19.4 | 4.8 MB | ########## | 100%
cached-property-1.5. | 10 KB | ########## | 100%
zlib-1.2.11.1 | 378 KB | ########## | 100%
scipy-1.6.0 | 23.2 MB | ########## | 100%
protobuf-3.14.0 | 261 KB | ########## | 100%
libprotobuf-3.14.0 | 2.3 MB | ########## | 100%
m2w64-gmp-6.1.0 | 726 KB | ########## | 100%
mkl-2020.4 | 172.4 MB | ########## | 100%
wrapt-1.12.1 | 46 KB | ########## | 100%
libblas-3.9.0 | 3.9 MB | ########## | 100%
termcolor-1.1.0 | 6 KB | ########## | 100%
markdown-3.3.3 | 66 KB | ########## | 100%
keras-preprocessing- | 33 KB | ########## | 100%
setuptools-49.6.0 | 919 KB | ########## | 100%
google-pasta-0.2.0 | 42 KB | ########## | 100%
certifi-2020.12.5 | 143 KB | ########## | 100%
m2w64-gcc-libs-5.3.0 | 520 KB | ########## | 100%
pyreadline-2.1 | 146 KB | ########## | 100%
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done

安装成功,但仍然出现上述错误。

最佳答案

我建议为您的 Python 版本使用包管理器 conda/miniconda。之后,按照正确的顺序执行以下步骤:

reticulate::use_condaenv("/your/path/to/miniconda3-4.7.12/")
reticulate::conda_create(envname = "r-reticulate")
reticulate::use_condaenv("/your/path/to/miniconda3-4.7.12/envs/r-reticulate")

# Verify if it was properly selected
reticulate::py_config()
## python: /your/path/to/miniconda3-4.7.12/envs/r-reticulate/bin/python
## ...

# tensorflow::install_tensorflow(version = "gpu")

# To install Keras
keras::install_keras(method = 'conda', envname = 'r-reticulate')
keras::is_keras_available()

关于python - 无法在 R 中安装 Tensorflow, "could not find a Python environment for {PATH}",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65542831/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com