我尝试在R中使用python包,但我一直收到相同的错误:
ImportError: cannot import name 'read_csv' from 'pandas' (unknown location)
我也不会用"py_install“:
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- python=3.1
Current channels:
- https://conda.anaconda.org/conda-forge/win-64
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Error: one or more Python packages failed to install [error code 1]
我尝试指定包所在的文件夹,但它不起作用。希望你们能帮上忙。
我的代码:
library(reticulate)
use_condaenv("C:/Users/Bruger/AppData/Local/r-miniconda/envs/r-reticulate")
import("pandas")
py = py_run_string
py("import pandas as pd")
py("from pandas import read_csv")
发布于 2021-12-10 12:13:05
Conda 4.10与python 3.10不兼容。
这个问题与R无关,也许你的代码没有什么问题。在以下SO问题中出现了相同类型的问题:
解决方案
如果您需要python 3.10+
如果你需要python 3.10或更高版本,你必须有conda 4.11或更高版本。安装所需的conda版本,或使用conda update conda
切换到基本环境和update conda。类似于:
conda activate base
conda update conda
conda create --name r-reticulate python=3.10 pandas numpy scipy matplotlib scikit-learn
conda activate r-reticulate
您可能需要向conda添加非默认通道,因为我使用它获得了一个UnsatisfiableError
。例如,通过使用conda-forge通道,我没有得到错误(但这可能会安装比通常更新的包):
conda create --name r-reticulate -c conda-forge python=3.10 pandas numpy scipy matplotlib scikit-learn
如果你想保留原来的conda
使用python 3.9或更早的版本安装其他环境,如
conda activate base
conda create --name r-reticulate python=3.9 pandas numpy scipy matplotlib sklearn
conda activate r-reticulate
其他症状
在创建并激活python 3.10环境之后,基本上不能安装任何东西。你甚至不能安装conda-build:
conda install conda-build -y
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
ResolvePackageNotFound:
- python=3.1
Conda 4.10 contains python 3.9 and conda 4.11 contains python 3.10,所以您的基础环境应该与其中的python版本兼容。
复制?
如果您认为您的问题是重复的,请删除它。
这个答案与meta是一致的。我相信这是一个exactly the same answer should be accepted的例子,但我也定制了这个问题的答案。
https://stackoverflow.com/questions/69551793
复制相似问题