conda: ResolvePackageNotFound python=3.1 [duplicate] - python

I'm trying to use python packages in R, but I keep getting the same error:
ImportError: cannot import name 'read_csv' from 'pandas' (unknown location)
I cant use "py_install" neither:
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]
I have tried to specify my folder in which the packages are in, but it doesn't work.
Hope you guys can help.
My code:
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")

Conda 4.10 is incompatible with python 3.10.
The issue is not related to R, and maybe there is nothing wrong with your code. The same type of problem occurred at the following SO issues:
PyTorch installation asks for python=3.1 . Python Version installed: 3.10.0
Trying to install Earth Engine on R; python=3.1 not available
Why can't I install matplotlib or pandas with pip OR miniconda?
Solutions
If you need python 3.10+
If you need python 3.10 or newer, you must have conda 4.11 or newer. Install the desired conda version, or switch to the base environment and update conda using conda update conda. Something like:
conda activate base
conda update conda
conda create --name r-reticulate python=3.10 pandas numpy scipy matplotlib scikit-learn
conda activate r-reticulate
You may need to add non-default channels to your conda, as I get an UnsatisfiableError using it. By using the conda-forge channel e.g., I got no error (but this may install newer than usual packages):
conda create --name r-reticulate -c conda-forge python=3.10 pandas numpy scipy matplotlib scikit-learn
If you want to keep the old conda
Install another environment from base with python 3.9 or older like
conda activate base
conda create --name r-reticulate python=3.9 pandas numpy scipy matplotlib sklearn
conda activate r-reticulate
Other symptoms
You basically cannot install anything after creating and activating your python 3.10 environment. You cannot even install 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, so your base environment should be compatible with the python version therein.
duplicate?
If you believe that your question is a duplicate, please check how you can improve it.
This answer is in agreement with meta. I believe this is an example where exactly the same answer should be accepted, but I also customized the answer to the question.

This works for me
library(reticulate)
x = import('pandas')
x$read_excel()
You can install the package in this way
py_install("pandas")

Related

Conda reports PackagesNotFoundError: python=3.1 for reticulate environment

I'm trying to use python packages in R, but I keep getting the same error:
ImportError: cannot import name 'read_csv' from 'pandas' (unknown location)
I cant use "py_install" neither:
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]
I have tried to specify my folder in which the packages are in, but it doesn't work.
Hope you guys can help.
My code:
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")
Conda 4.10 is incompatible with python 3.10.
The issue is not related to R, and maybe there is nothing wrong with your code. The same type of problem occurred at the following SO issues:
PyTorch installation asks for python=3.1 . Python Version installed: 3.10.0
Trying to install Earth Engine on R; python=3.1 not available
Why can't I install matplotlib or pandas with pip OR miniconda?
Solutions
If you need python 3.10+
If you need python 3.10 or newer, you must have conda 4.11 or newer. Install the desired conda version, or switch to the base environment and update conda using conda update conda. Something like:
conda activate base
conda update conda
conda create --name r-reticulate python=3.10 pandas numpy scipy matplotlib scikit-learn
conda activate r-reticulate
You may need to add non-default channels to your conda, as I get an UnsatisfiableError using it. By using the conda-forge channel e.g., I got no error (but this may install newer than usual packages):
conda create --name r-reticulate -c conda-forge python=3.10 pandas numpy scipy matplotlib scikit-learn
If you want to keep the old conda
Install another environment from base with python 3.9 or older like
conda activate base
conda create --name r-reticulate python=3.9 pandas numpy scipy matplotlib sklearn
conda activate r-reticulate
Other symptoms
You basically cannot install anything after creating and activating your python 3.10 environment. You cannot even install 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, so your base environment should be compatible with the python version therein.
duplicate?
If you believe that your question is a duplicate, please check how you can improve it.
This answer is in agreement with meta. I believe this is an example where exactly the same answer should be accepted, but I also customized the answer to the question.
This works for me
library(reticulate)
x = import('pandas')
x$read_excel()
You can install the package in this way
py_install("pandas")

Errors while installing ROOT

I'm new to Python. I installed miniconda to get packages iminuit and minuit. To do this, I created a new environment to avoid conflicts. But when I try to install minuit with the command
conda install minuit -c conda-forge
I get the following error messages:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- minuit
Current channels:
- https://conda.anaconda.org/conda-forge/osx-64
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/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.
How can I solve this?
Exactly as the messages say, the package isn't available in the current channels. If you look on anaconda.org you will find:
https://anaconda.org/mutirri/minuit which says:
To install this package with conda run one of the following: conda install -c mutirri minuit conda install -c mutirri/label/all minuit
I'm not sure of the versioning of CERN's ROOT packages, but I guess that they no longer support Minuit package, instead Imminuit which is more lightweight and Jupyter friendly.
So you can install this package with this command, according to here:
conda install -c anaconda iminuit

Python Package not Found when Trying to Install on Anaconda Powershell

I am trying to install PyPDF2 on Anaconda via the Anaconda Navigator to be used with JupyterLab. I am faced with the following error:
(base) PS C:\Users\luke.xuereb> conda install PyPDF2 Collecting package metadata (current_repodata.json): done Solving environment:
failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done Solving environment:
failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from
current channels:
pypdf2
Current channels:
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.
I have also attempted this with a few other Python packages such as Tabula and natsorted, and both resulted in the same outcome.
I've also tried changing the environment following some research by doing the following:
conda create --name myenv
conda activate myenv
Again, this did not work. Any help would be appreciated, thanks.
Worked for me by running: conda install -c conda-forge pypdf2 as the pypdf2 package has a package in conda forge. https://anaconda.org/conda-forge/pypdf2
EDIT: Also, why didnt creating a new Environment work? If the command isnt found, you may have to add conda to your PATH envirnment variable.

conda-forge PackagesNotFoundError for pygraphviz

I am trying to install pygraphviz but conda is not finding it in the channels. Below is the error I get. Conda-forge is already in the channel list and I tried with -c conda-forge but still does not work. I also tried bioconda channel and did not work.
> conda install -c anaconda pygraphviz
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- pygraphviz
Current channels:
- https://conda.anaconda.org/anaconda/win-64
- https://conda.anaconda.org/anaconda/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
- https://conda.anaconda.org/conda-forge/win-64
- https://conda.anaconda.org/conda-forge/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.
Pygraphviz should be there in bioconda and conda-forge according to the documentation, but I still cannot find the package.
I also update conda conda update conda, and still no luck.
Is there something wrong here? or something I am missing?
You are installing it from the wrong channel. Do:
conda install -c conda-forge pygraphviz
Updates: Windows
It appears that there are challenges installing pygraphviz on windows. Assuming that graphiz is installe and added to Path, which is a separate program (not python library) these solution might work
# Tom Hanks’ answer
conda install graphviz pygraphviz -c alubbock
See SO answers Installing Pygraphviz on Windows
"conda install graphviz pygraphviz -c alubbock" worked for me, within an Anaconda cme.exe terminal (and several failed attempts with other approaches). Elsewhere I had also been told to install a C+ compiler, which I did within Visual Studio. But maybe you can try without installing the C+ compiler

Conda refuse to install packages from requirements.txt just because of a few outliers, how to fix it?

I'm using requirements.txt to manage my python dependency:
six
tqdm
future
numpy
brine
scipy
matplotlib
# birdseye
shapely
git+https://github.com/tribbloid/jupyerlab-desktop.git#subdirectory=python
jupytext
# pyre-check
# deprecated
torch >= 1.2.0
# tensorboard
# opencv >= 4.0.0
# prototypes
git+https://github.com/pytorch/vision.git#v0.4.0#egg=torchvision
tb-nightly
My environment is a conda env on python 3.7. I was trying to use a few command to install these packages, but when I run:
conda install --file requirements.txt
I got the following error message:
$ conda install --file ./requirements.txt
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- tb-nightly
- //github.com/tribbloid/jupyerlab-desktop.git
- torch[version='>=1.2.0']
- //github.com/pytorch/vision.git#v0.4.0
- brine
Current channels:
- https://conda.anaconda.org/conda-forge/linux-64
- https://conda.anaconda.org/conda-forge/noarch
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/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.
It appears that conda refuse to install any of them simply because it can't find 3 packages! (they are on PyPI) What's the point of this design and what should I do to fix it?
My end goal is to use conda if possible, and fallback to pip if they are only on PyPI, the entire process should be reproducible and fully automated.
You can delete offending packages from requirements.txt, run conda on the new .txt, then install non-installed packages via pip into your Anaconda/pkgs (or move them there manually post-install). Then, run conda update --all to ensure compatibility.
Worked for me for a similar instance.
This works on Linux. Just install via pip in your conda environment, it won't complain about not finding the packages like conda.
Run pip install -r requirements.txt. This will install the packages in your conda environment plus all their dependencies.
Make sure to activate your environment and that you are running this command in the directory where your requirements.txt is i.e in terminal cd to wherever requirements.txt is.
I thought to try only after installing keras and tensorflow via pip so I can't say 100% that it would've worked for those as well, but everything else in my req file (+50 modules) installed with this command on Win11 in Anaconda Powershell while in the active environment.
conda install -c conda-forge --file requirements.txt
I still don't know why I needed to do this. Also, I tried another req file that I didn't have a problem with weeks prior. It also failed as the OP states. I don't know what I may have done (not done) to cause this. Perhaps missing a conda update or server down.

Categories

Resources