Conda is not accepting dependencies - python

I am using snakemake as workflow manager. I first create a conda environment in JupyterLab (anaconda) with: conda create base. Then I activate a .yaml file with mamba env create --name <name of the env> --file environment.yaml. In the .yaml file I include among other the following dependencies: R = 4.1.3, tensorflow = 2.8.0. At this point I get an error message:
Encountered problems while solving:
nothing provides requested r 4.1.3**
nothing provides requested tensorflow 2.8.0**.
As far as I understand, the dependencies are going to be take care of by conda in the local environment. I eventually installed manually tensorflow in the local environment with pip install tensorflow. Nevertheless, I get the same error message when I try to activate the .yaml file. I know that I have already installed R.
What should I do ? I have Ubuntu 20.04.4 LTS.
Many thanks.

Packages are not found because the current highest versions of tensorflow from conda is 2.7.0 and the highest available for R is 4.1.0, so you have to downgrade if you want to install using conda.
For tensorflow, you can tell conda to use pip instead, but I don't know if there is a similar workaround for R.
Edit: Fixed R version

Related

Segmentation fault: 11 when trying to run Spyder in conda environment

I'm setting up a separate environment to work in. However, whenever I try running spyder, I receive this error:
/Users/user/anaconda3/envs/myenv/bin/pythonw: line 3: 84700 Segmentation fault: 11 /Users/user/anaconda3/envs/myenv/python.app/Contents/MacOS/python "$#"
I have no idea what this means. The commands I used to get to this point were:
conda create -n myenv python
conda activate myenv
conda config --add channels conda-forge
conda install -c conda-forge spyder
spyder
I have anaconda navigator installed, and spyder runs fine in the root environment. I do receive the statement "link image0 hasn't been detected!" every time I run it.
I've always used spyder and anaconda, and I've never had these issues before
I was dealing with this same problem for several weeks and spent many days trying to fix it. Of the countless operations I attempted, I finally got spyder to successfully run from its own conda environment without throwing the segmentation fault error you've referenced.
With a fresh install of anaconda3 on macOS 10.14.6, I created a conda environment from the command line just as you’ve shown:
conda create -n myenv python
conda activate myenv
A comment about:
conda create -n myenv python
Note 1: if you list “spyder” to install during the environment creation there’s no need to include “python” as a package unless you wish to have a specific version. For example, “python=2.7.9”, or “python=3.10.*”. Otherwise, python gets added automatically when the environment is created.
Next,
conda config --add channels conda-forge
instead of setting the conda configuration to use the conda-forge channel and instead of including it as a channel when installing spyder into your conda environment, simply install spyder using the virgin (unmodified) default channel configuration by only typing:
conda install spyder
Now when you run spyder from the command line within your active environment it should open as expected.
As previously indicated, you can install spyder during the environment creation:
conda create -n myenv spyder
Then you can activate the environment to test everything:
conda activate myenv
spyder
Note 2: the official spyder documentation recommends including the -c conda-forge channel, but this was the entry that I removed to finally avoid the segmentation fault. I suspect that although the community repository at conda-forge keeps the most up-to-date versions, there are conflicts not being resolved at creation of the new local environment.
Furthermore, you may notice that the method described above installs spyder version 5.3.3 and spyder-kernels version 2.3.3, both of which are not the most up-to-date. You could check this by running conda list from the command line and then searching for the corresponding entries.
However, if you try to update spyder by calling conda update spyder, the system will tell you that all packages are currently installed. This is because the virgin channel defaults are looking at the anaconda repository, not conda-forge. My suggestion for right now is not to attempt updating spyder in your conda environment because it will update other packages as dependencies that will result in breaking the application again.
In case you’re curious, to get the most recent version of spyder based on the procedure I've described above would be by setting the channel as follows: conda update spyder -c conda-forge. Depending on your OS, this will install spyder 5.4.1 and spyder-kernels 2.4.1 (as of 16-Jan-23), but it will also remove and update several other packages, hence causing compatibility issues.
UPDATE:
My key takeaway is to remove the -c conda-forge from the installation line of code to prevent the segmentation fault when using conda. Everything else is up to the user. Installing with pip, brew, or any other method is discretionary but could also result in more trouble than it’s worth for the already frustrated user.
If you run conda create -n myenv spyder at the environment creation or conda install spyder after creating the environment, the packages pyqt and qtpy are installed alongside spyder because they are dependencies and not explicitly needed (unless specifying specific versions). If you run pip install spyder, the packages pyqt5 and qtpy get installed. (as of 16-Jan-23)
Caution:
(with reservation because if you can follow instructions and you are both okay with and the only one affected by the consequences of your choices when things go wrong, I support you to thoughtfully experiment and explore if you so desire)
According to the docs, using pip to install packages within the conda environment is reserved for experienced users. A big reason for this caution is because pip and conda don’t communicate and so package versions and dependencies can become incompatible if the user is not aware of what’s happening. It should also be pointed out that if and when using pip, one should generally install all the desired conda packages prior to installing a package with pip. Problems usually present themselves when updating, or installing with conda after pip. When this becomes necessary the general advice is to start over and install new packages as well as updated versions in a new environment.
Installing with brew is unsupported by the spyder devs. This can be referenced from the spyder documentation.

How to install new package with conda without breaking the existing Kedro installation?

I have a working conda environment with Kedro installed. The .yml file is available by the link 1. My kedro pipelines work fine in this environment. However, when I try to install matplotlib package with conda I have the following warning:
The following packages are causing the inconsistency:
conda-forge/noarch::pyspark==3.2.1=pyhd8ed1ab_0
Conda somehow resolves it I suppose because it suggests installing the required packages. When I try to run kedro in this updated environment I face the error:
kedro.io.core.DataSetError: Object ParquetDataSet cannot be loaded from kedro.extras.datasets.pandas.
It seems like the problem is that conda updates some packages which are no longer consistible with kedro. How can I install the matplolib pkg using conda without breaking kedro?

python can't find conda packages but can find pip packages

I'm sure this might be a common problem but I've scoured the StackOverflow and read through all the recommended posts that StackOverflow gave me before posting. However, I've installed tensorflow on conda but not on pip. When I run Python, I can't run import tensorflow since it gives me ModuleNotFoundError: No module named 'tensorflow'. This leads me to believe that conda installs the packages to a different place than pip, but I'm not sure how to make them install to the same place. I recall a long time ago, the problem being related to usr/bin and usr/local/bin or something, but I don't remember how that goes or the solution.
Any links / tips would be appreciated!
Please follow the below steps:
The below command will list all the environments in the system and their path
conda env list
Please activate the corresponding environment using the below command
conda activate <env_name>
You can list the pip/conda packages that you have installed in the activated environment using the below command
pip freeze
conda list
If tensorflow is not listing, please install tensorflow again using the below command
pip install tensorflow
If still you are facing issue check the PATH variable in control panel and set python path.

How do I resolve an error installing symfit - `Cannot uninstall sympy`

I installed Anaconda3 and need to install symfit. Using pip install symfit, the program returns the error: Cannot uninstall sympy. It is a distutils...." It seems symfit requires sympy 1.1.1, but my Anaconda installation already installed sympy 1.3 and the symfit installer objects to that. How can I get around this incompatibility?
Thanks.
One of the solution is to create a new conda environment and try out the installations in that environment to avoid the conflict between different package versions. Tried the same in Centos and it is working fine.
Try out the following steps:
1) Create a conda environment:
conda create -n my_env python=3
2) Activate the environment:
source activate my_env
3) Install the symfit package
pip install symfit
Please note that 'my_env' is the environment name. Hope this solves your issue.
Regards,
Dona
Yes, installing spyder and symfit within the virtual environment worked perfectly and my original problem installing symfit and running my program are solved. A few other commands from the Anaconda prompt I learned working with virtual environments are "where spyder", which locates the various instances that have been installed and "conda info --envs", which lists the virtual environments that have been created. Thanks again.

"No module named tensorflow" after pip install in Anaconda Environment

I just started to learn how to use Anaconda to manage packages. I am trying to install tensorflow in conda environment. So first of all, I create an environment by:
conda create -n tensorflow
Then, I source it by:
source activate tensorflow
I can see my prompt changed so I think it is going right.
I notice that it seems that the tensorflow environment is copying from ~/anaconda2/lib/ where I do have my root version python2.7 and tensorflow0.12.0
I installed a new version Python in tensorflow environment by:
conda install python=3.5
Then, I follow the steps to install tensorflow by:
pip install --ignore-installed --upgrade TF_PYTHON_URL
However, when I do conda list, I can only see Python3.5 but not tensorflow1.0. I also failed to import tensorflow when I am in Python.
So I have two questions that really confuse me.
Why does the pip installed tensorflow not show up when I do conda list?
Although I conda install python=3.5 and I can see it from conda list, I am not using python 3.5 when I enter Python directly. It seems still using Python2.7, which comes from my root environment.
I appreciate any tutorial on how anaconda works.
I think your pip install is installing into the global environment instead of
tensorflow. Why don't you try installing by specifying the path? For example pip install --target $HOME/anaconda3/tensorflow tensorflow(Where the first tensorflow is your environment and the second is the actual package).
I just saw the last two questions. So you actually see the tensorflow you installed with pip? I am confused now. Type which pip to see if it is running from the tensorflow environment or the global. You could also try source deactivate before source activate tensorflow just to make sure that you are not using a different environment, then run which python. It should show your new environment.
If you want to create an environment using a specific version of Python (rather than the system default), you can do for example:
conda create --name myCoolEnv python=3.5
and then activate with
source activate myCoolEnv
You can read more about Anaconda environments here.

Categories