How to install packages in conda that are not available in anaconda - python

I want to install a package (of python) using conda, but says not available in repo.anaconda.com/......., how could I install it ?
The specific package that I tried to install is edx-dl (link of the github repo) using the code conda install edx-dl. This code works fine with pip but not with conda.
For example, in pip if I type pip install edx-dl was able to install the package when I was using python base without anaconda. But now with conda it says it is not available in anaconda repo. So if a package that are not available in anaconda, can be installed?
So to generalize, is there any way to download and install packages of python using conda which are not available in repo.anaconda.com?
Note that, I do not use base python, rather currently using anaconda. So, can't use pip to install that package.
Thanks!
Error message that I got:
(base) C:\WINDOWS\system32>conda install edx-dl
WARNING conda.base.context:use_only_tar_bz2(632): Conda is constrained to only using the old .tar.bz2 file format because you have conda-build installed, and it is <3.18.3. Update or remove conda-build to get smaller downloads and faster extractions.
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
edx-dl
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.

in terminal type:
conda activate <env_name>
then:
pip install edx-dl
will work on conda env this library

Thanks #Kasper for your answer. Following your answer, I was able to solve the problem. Here I give the complete procedure for anyone who is new.
Step 1: Open "Anaconda Prompt". (I opened as "Run as Administrator" to avoid any problem in installation.)
Step 2: type conda info --envs to cheek your available environments.
one environment for sure you should have is base & another one
Classes_and_Inheritance also should appear.
I had PyCharm installed, so with that I had to open some projects. So, I had some additional environments too.
Step 3: type conda activate <environment_name>
this environment_name should be substituted by your preferred environment
(i.e. base, Classes_and_Inheritance or any other environment
that you have created. )
In my case, I used conda activate PyCharm_Proj, but if you want, you can use this conda activate base
Step 4: type pip install <package_name>. The package_name should be substituted by the name of the package name you want to install. (i.e. in my case I typed pip install edx-dl)

Related

using requirements.txt to automatically install packages from conda channels and pip in a new conda environment

I'm trying to set a conda environment using a requirements.txt file that a coworker shared with me. My coworker uses Python in a Mac without Anaconda, and I'm using it in a Windows machine with Anaconda. The file requirements.txt was generated with the command pip freeze and looks like this:
absl-py==0.7.1
affine==2.3.0
agate==1.6.0
agate-dbf==0.2.0
agate-excel==0.2.1
agate-sql==0.5.2
...
After checking the answer of this question, I tried the following in the Anaconda terminal:
conda create --name my-env-name --file requirements.txt
Which fails with the following error message:
PackagesNotFoundError: The following packages are not available from current channels:
- appscript==1.0.1
- style==1.1.0
- senticnet==1.3
- scikits.optimization==0.3
...
My understanding is that this happens because those packages are not available in the Anaconda package installation channels, and that they should be installed instead via pip with my conda environment activated, using pip install -r requirements.txt
The problem is that this list of packages is very long, and I would like to avoid having to manually check and separating which packages are included in Anaconda channels and which should be installed via pip. Then, is there a way to tell Anaconda to create an environment by automatically recognizing the packages included in its channels, installing them, and then installing the rest using pip?
Using requirements.txt with conda
There's no problem at all using a requirements.txt file when creating a conda environment.
In fact, you can also set additional channels at creation time:
conda create --name my-env-name --file requirements.txt --channel <NAME_OF_CHANNEL>
for example, in the case of the first package you mention, you can install it from anaconda channel. So you could run:
conda create --name my-env-name --file requirements.txt --channel default --channel anaconda
Why using default channel first? Well, just to give preference to the default one (the priority of channels is specified by the order they are listed: higher priority from left to right).
When at least some of the packages are not available using conda
Well, when no conda channel can provide any of your required packages, there are several alternatives:
Install through conda those packages available in any of its channels.
Install through pip the rest.
Create a conda environment.yml file:
conda env export > environment.yml
When you need to recreate this environment, then you can do:
conda env create --name my-env-name --file environment.yml
and it will install the packages using conda, will install pip, and then will install those packages only available with the latter one.
This approach has good and bad properties:
one of the good properties is that it separates those packages installed through conda from those installed using pip.
one of the bad properties is that it's only useful for conda, but not for pip alone.

How add channel for wolframclient using conda?

I want to use the wolframclient Python package in Mathematica. The docs suggest using pip install wolframclient.
However, my main Python installation is within conda, so I do not want to use pip, but instead a standard conda install wolframclient. (The problem with using pip is that the added package's dependencies may interfere with what conda has already installed and knows about.)
The wolframclient package is at https://pypi.org/project/wolframclient/. But by default conda does not know about pypi.org. I tried the command conda config --add channels pipy, but conda install wolframclient says the channel is "not accessible or is invalid".
I think the problem is that the files at https://pypi.org/project/wolframclient/ are not already in the form of a conda package.
How might one proceed?
I think the problem is that the files at https://pypi.org/project/wolframclient/ are not already in the form of a conda package.
Yes, very precisely noted. Conda packages contain information about how to built in different format than pypi packages, which are made for pip.
In the case you describe, you ahve several options:
Create a seperate environment for wolframclient and use pip install wolframclient in there. Yes, pip and conda do not always get along, but by creating a virtual environment you have no risk of breaking other stuff and pip will be happy installing wolframclient for you
Check the wolframclient package on pypi and install the dependencies using conda before installing wolframclient with pip which might minimize the risk of having to many packages downloaded by pip
Download the source code of wolframclient and built it into a local conda package using conda build and this guide and then use conda install to install the locally built package
I have created a conda build of wolframclient (current version: 1.1.4).

Conda install and update do not work also solving environment get errors

I am using anaconda as below:
(base) C:\Users\xxx>conda info
active environment : base
active env location : C:\Users\xxx\Documents\ANACONDA
shell level : 1
user config file : C:\Users\xxx\.condarc
populated config files : C:\Users\xxx\.condarc
conda version : 4.7.11
conda-build version : 3.18.9
python version : 3.6.9.final.0
virtual packages :
base environment : C:\Users\xxx\Documents\ANACONDA (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/win-64
https://repo.anaconda.com/pkgs/free/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
package cache : C:\Users\xxx\Documents\ANACONDA\pkgs
C:\Users\xxx\.conda\pkgs
C:\Users\xxx\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\xxx\Documents\ANACONDA\envs
C:\Users\xxx\.conda\envs
C:\Users\xxx\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.7.11 requests/2.22.0 CPython/3.6.9 Windows/10 Windows/10.0.16299
administrator : False
netrc file : None
offline mode : False
Now I have 2 issues that stop my work.
1) I cannot use conda install for any package.
It will give me the error in solving environment list this:
failed with initial frozen solve. Retrying with flexible solve.
then it will fail again and give message like this:
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
Even after the checking for incompatible packages, it didn't give me the solution.
2) When I want to upgrade or downgrade conda by the command:
conda update -n base conda
or
conda install conda = 4.6.11
It will give me errors again in the solving environment, and I think this is related to the first issue.
Now I cannot use conda for anything, please advise and thank you!
I ran into the same problem and I couldn't find a solution, but I did find a workaround. If you create an env and activate that env and then do the install, it seems to work just fine. If you don't need a lot of libraries I would try that.
Commands are:
Create env
conda create --name myenv
Activate the env
conda activate myenv
I started running in to this problem when one package suggested following modifications before installation
conda config --set channel_priority true
so I just reverted it and voila error's gone
conda config --set channel_priority false
I solved a similar problem by doing the following:
conda update --all --yes
You may downgrade to an older version of conda 4.6.14 and then install your packages.
conda config --set allow_conda_downgrades true
conda install conda=4.6.14
If your conda version is greater than or equal to 4.8, you may see that error.
(base) [localhost ~]$ conda --version
conda 4.8.2
(base) [localhost ~]$ conda install -c anaconda requests-kerberos
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.
Downgrade your conda if possible using the following commands
conda config --set allow_conda_downgrades true
conda install conda=4.6.14
Then create your virtual environment:
conda create --name myenv_conda
Then activate your myenv_conda
conda activate myenv_conda
Now try to install packages using conda -c install anaconda
eg: conda install -c conda requests-kerberos
output:
(myenv_conda) [localhost ~]$ conda install -c anaconda requests-kerberos
Collecting package metadata: done
Solving environment: done
....
....
....
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
https://stackoverflow.com/a/61117831/7802476 helped me. Creating a new environment using the accepted answer didn't get my jupyter notebook to recognize the installed opencv. I could only import cv2 when I was in the environment on my terminal.
The fix was to use pip instead of conda, pip install opencv-python
I run into same problem while installing geopandas. The issue was gone after I upgraded to a newer version of Anaconda using:
conda update --prefix C:\apps\anaconda3 anaconda
Note: you'll have to modify the path C:\apps\anaconda3 pointing to your own installation directory.
Strangely, I did download Anaconda from the official homepage just a few hours ago and thought I had the newest version...
I had same problem but I solved because of SKİD.
After you create new env, You can run one of the codes in this link.
https://anaconda.org/rdkit/rdkit
I've generally had good results with conda and pip, but learned over time that environments really can get broken by unusual combinations of packages, and just starting a new env from scratch is often the only way forward. In my case it was tensorflow-gpu that wouldn't install from conda-forge, into an env I'd already been using for some weeks. The list of packages cited as being incompatible was in the dozens. I tried all the things listed on this page, but in the end I just hammered out a new env. Since I was deducing what packages I needed to install in the new env by running my program and installing one package at each error (ie instead of being methodical about listing my former env), along the way I reproduced this frozen solve thing several times. Each time it happened, I shuffled that conda package back to the initial conda create command and started again. Eventually my program ran in the new env, with tensorflow-gpu imported, and the root cause was revealed as conda installs which occur after pip installs. It wasn't anything to do with conda version or conda config.
A specific note for anyone using opencv-python, I ended up needing to install qt via conda, before attempting to install opencv-python via pip. That was a tricky one because it's a runtime error, and on stack overflow many of the solutions refer to various qt lib requirements which aren't part of python/conda and which I already had.
A further specific note. Some pip installs will roll back a version of a related package, thus breaking other conda-installed packages. In my case the example was a package called peakutils rolling back numpy, which then broke a from numpy import ma in scale.py module in the matplotlib package. My head is still spinning.
Create a new environment if your are not superuser, after that activate environment to install packages
Recommend to upgrade conda latest version.
conda install --quiet --yes conda=4.7.11
python -m pip install --upgrade pip==19.2.2

conda install downgrade python version

I'm trying to downgrade python version of anaconda via conda install python=3.3, but have following error:
~/anaconda3/bin$ ./conda install python=3.3
Fetching package metadata .........
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
- gevent -> python 2.6*
- python 3.3*
Use "conda info <package>" to see the dependencies for each package.
How to resolve conflicts with the packages?
If you want to set specific version, use it like this:
WARNING: This command will overwrite the default python version system-wise
conda install python=3.6
To create environment with a specific version, you can do:
conda create -n $PYTHON36_ENV_NAME python=3.6 anaconda # set custom env name
The anaconda at the end allows the env to use all anaconda packages
For more information refere to Anaconda documentation
There are two ways to downgrade python in anaconda.
1. Downgrade python in the active environment
(This can lead to conflicts with installed packages for higher python versions)
conda activate nameOfYourEnvironment
conda install python=3.3
2. Create a new environment
(This is a more safer way, but you need to install all necessary packages again)
conda activate base
conda create --name env_name python=3.3
Hint: Use conda list before creating a new environment to get the names of all installed packages in the actual environment.
If you want to check your installed environments do:
conda env list
If you got problems in installing, make sure to run the shell as administrator (always recommended).
You can make environments with other versions of Python using this command:
conda create --name py33 python=3.3
source activate py33
Very firstly check the current version using command python --version. Then on anaconda prompt type the command conda search python which will list all the python versions available till date. Then from that list select your version and type conda install python=3.5.2 or any of your choice

Conda: Installing / upgrading directly from github

Can I install/upgrade packages from GitHub using conda?
For example, with pip I can do:
pip install git+git://github.com/scrappy/scrappy#master
to install scrappy directly from the master branch in GitHub. Can I do something equivalent with conda?
If this is not possible, would it make any sense to install pip with conda and manage such local installations with pip?
The answers are outdated. You simply have to conda install pip and git. Then you can use pip normally:
Activate your conda environment source activate myenv
conda install git pip
pip install git+git://github.com/scrappy/scrappy#master
There's better support for this now through conda-env. You can, for example, now do:
name: sample_env
channels:
dependencies:
- requests
- bokeh>=0.10.0
- pip:
- "--editable=git+https://github.com/pythonforfacebook/facebook-sdk.git#8c0d34291aaafec00e02eaa71cc2a242790a0fcc#egg=facebook_sdk-master"
It's still calling pip under the covers, but you can now unify your conda and pip package specifications in a single environment.yml file.
If you wanted to update your root environment with this file, you would need to save this to a file (for example, environment.yml), then run the command: conda env update -f environment.yml.
It's more likely that you would want to create a new environment:
conda env create -f environment.yml (changed as supposed in the comments)
conda doesn't support this directly because it installs from binaries, whereas git install would be from source. conda build does support recipes that are built from git. On the other hand, if all you want to do is keep up-to-date with the latest and greatest of a package, using pip inside of Anaconda is just fine, or alternately, use setup.py develop against a git clone.
I found a reference to this in condas issues. The following should now work.
name: sample_env
channels:
dependencies:
- requests
- bokeh>=0.10.0
- pip:
- git+https://github.com/pythonforfacebook/facebook-sdk.git

Categories

Resources