Unable to uninstall package in anaconda environment - python

I currently have tensorflow and tensorflow-gpu installed in a pre-made conda environment. I want to remove tensorflow but whenever I use
conda remove --name carnd-term1 tensorflow
I get the following error message
Fetching package metadata ...........
Solving package specifications: .
PackageNotFoundError: Package not found: Conda could not find '
Why I can't remove the package?

Are you sure whether you used conda to install tensorflow because the packages whatever you install using conda will be under ~/anaconda so if you get the error then it means that it is installed in some other path so print sys.path from where you can know the paths that python looks for library and you can manually remove the packages by looking at those paths. As of my knowledge if you have used conda then the package should be under ~/anaconda if you used pip/pip3 the package will be under respective python directory.

Related

Pip is uninstalling pytorch built from source when i use 'pip install <some other package that needs pytorch>'. Is there a way?

I needed to build pytorch from source in order to use the latest cuda toolkit - hence I did that. My environment is a conda enviornment.
The package I am trying to install is allennlp.
Pip list is not showing torch installed, conda is showing it is.
Tried building allennlp from source through:
conda skeleton pypi <package>
conda build <package>
conda build is also causing problems due to incompability with pip packages etc...
I am just wondering if there is a simpler way to do this?
For example: Tell pip that torch is already installed so it stops uninstalling the current torch (why can't it just pick it up as installed).
Appreciate the help!
You can install allennlp with pip install --no-deps allennlp, but then you have to make sure the other dependencies are there yourself.

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).

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

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)

conda equivalent of pip install

If I have a directory with setup.py, in pip, I can pip install . in the directory to install the package.
What if I am using conda?
conda install . makes conda to find a package named dot.
conda packages are a different structure than standard python packaging. As a result, the official, recommended and best-practice approach is to use conda to install pip within an activated conda environment, and use that to install standard packages:
conda install pip
NOTE: You want to use conda packages whenever they're available, as they have more features within a conda environment than non-conda packages.
conda install pip will install pip within the currently activated conda environment, and will ensure that it is integrated with conda so that, for example, conda list, will include any packages installed with pip.
NOTE: Commands like conda update will ignore pip installed packages, as it only checks conda channels for available updates, so they still need to be updated using pip. See this Question/Answer discussion:
Does conda update packages from pypi installed using pip install?
NOTE: See #kalefranz comment below regarding conda 4.6 experimental handling of packages.
If you're interested in creating your own conda package(s), take a look at this question/1st answer for a great run-down:
How to install my own python module (package) via conda and watch its changes
If you simply wish to install non-conda packages, using pip is the correct, and expected, way to go.
You can use pip install from within conda environment.
Just activate your environment using:
$ conda activate myenvironment
and use pip install . to install your package in environment's directory.
EDIT: As pointed by Chris Larson in another answert, you should install pip inside the environment using
$ conda install pip
in order to register packages correctly.
If I have a whl file, I can use pip install xxx.whl to install it.
From the documentation, conda install from a local file is also available, but the file should be a tarball file, i.e. .tar.bz2 files.
conda install /package-path/package-filename.tar.bz2 works. And if I have multiple tarballs, I can tar them to get a .tar file, then conda install /packages-path/packages-filename.tar installs the packages in it.

Can conda install source distributions?

Can conda install be used to install source-distributions (i.e. non-archived import packages that have a setup.py)?
Yes and no. You can not conda install per se. However, as the Conda documentation says, Conda ships with pip, so you should be able to pip install -e . your package. You can also install with traditional python setup.py [install|develop].
Remember to activate your Conda environment before installation if you're using one instead of site packages.
As mentioned by vaiski, you can use pip and/or setup.py to build and install the package, but this method is not ideal because packages installed with pip and conda do not respect each other's dependencies.
Thus, if the source distribution includes a conda build recipe (meta.yaml), then you can created the anaconda archive on your own machine by using the conda-build tool:
$ conda build meta.yaml
Afterwards, you will have a local tar.gz of the build package with meta-data that conda can understand. This is what you download from the internet whenever you install a package using conda.
Finally, you can install the package you built locally using:
$ conda install --use-local

Categories

Resources