Unable to update or install any package - python

I am trying to update matplotlib but getting an error. Error message : EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: C:\Users\DeepakKumar\Anaconda3 How to fix this issue?
Some Specs:
Anaconda3 2019.10
Python 3.7.4 64-bit
matplotlib 3.1.1

If you are using Windows, try to open your shell as an administrator and then run pip/conda install that will install it.
Also, I highly recommend using virtual environments to install libraries and avoid conflict in dependencies.
You can use virtualenv: https://virtualenv.pypa.io/en/latest/
Or conda management environemnts.
Basically, you create a new environment:
conda create -n my_env
conda activate my_env
conda install matplotlib
This will avoid these kind of problems.
You can also read more about it here: conda-envs

Search for Anaconda Prompt, Run the Prompt as Administrator (Right Click and select Run as Admin), then use conda update <package>, this shall solve your current issue, but this is just a workaround.
As Admin you should run conda update -n base -c defaults conda. This way your Anaconda should now update without admin related errors.

Related

conda update conda does not update conda

I had some problems with anaconda, so I decided to uninstall and reinstall it.
To do that I used anaconda-clean and ran the following command:
rm -rf ~/opt/anaconda3
The version that was installed is 4.12.0 and I wanted to update to the most recent, 22.9.0, but whenever I run
conda update conda
or
conda update -n base conda
and check the version
conda --version
I keep getting 4.12.0
Is there a way to solve this or find out if something went wrong when I deleted/installed anaconda?
Thanks!
Lu
Running conda update conda will make a best-effort attempt to update your environment. Unfortunately, you may have packages installed that prevents the update.
You can alternatively try a more explicit install:
conda install -n base conda=22.9.0
If this still fails please open an issue at https://github.com/conda/conda so the conda team can help debug further.
You likely have an old version of python in your base env with dependancies preventing automatic python update.
Running conda update python may solve this problem.
alternatively, you can install a specific version of python explicitly e.g.,
conda install python=3.9

How can i remove the effect of "pip3 install conda"?

I tried to install Conda on Kali Linux. I used the command $ pip3 install conda after that i try to run anaconda but nothing happen, so I go to the website and install the anaconda for linux64 then I install it successfully but when i run the script
$ source /home/faidey/anaconda3/bin/activate
$ conda init
The following message appears:
conda init
no change /home/faidey/anaconda3/condabin/conda
no change /home/faidey/anaconda3/bin/conda
no change /home/faidey/anaconda3/bin/conda-env
no change /home/faidey/anaconda3/bin/activate
no change /home/faidey/anaconda3/bin/deactivate
no change /home/faidey/anaconda3/etc/profile.d/conda.sh
no change /home/faidey/anaconda3/etc/fish/conf.d/conda.fish
no change /home/faidey/anaconda3/shell/condabin/Conda.psm1
no change /home/faidey/anaconda3/shell/condabin/conda-hook.ps1
no change /home/faidey/anaconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change /home/faidey/anaconda3/etc/profile.d/conda.csh
no change /home/faidey/.bashrc
No action taken.
So when I try to do the script $ sudo conda init the following message appears:
ERROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer. You can download the miniconda installer from
https://conda.io/miniconda.html.
What can I do to remove the effect of first script $ pip3 install conda and run anaconda successfully?
Which shell are you using? As the .bashrc is already modified by conda, you should be able to use conda as normal user. Maybe you have to restart the shell. If you are using zsh or another shell, you might have to modify the configuration manually.
If you really want to use conda as root user, you could try the following steps:
You could try to remove the pip version of anaconda calling $pip3 uninstall conda. Now $conda init should work as root user. If not proceed with step 2.
You could try to find out which binary is the correct one by calling $which conda as normal user and use the absolute path to initialize conda.

Installing python packages on anaconda on macos

This may be a silly simple question, but I couldn't find an answer in the documentation of Anaconda or elsewhere. I am a bit of a noob when it comes to Python and I am trying to install a package. The problem is generalizable to other packages.
specs
I am working on a macOS Catalina (10.15.5) and using Anaconda as my python environment (python2.7).
problem
I am attempting to install the package pyLDAvis in my python environment, but the package isn't available on Anaconda's environment manager, and pip or conda install isn't working on the Spyder shell. Do pip and conda installs only work on the Anaconda Prompt? The problem is that I have read that the Anaconda Prompt only exists on Windows, and I am on mac. How could I install packages (pip, conda, or else) on Anaconda?
Am I missing something?
Any help or pointers to documentation would be great! Thanks
Assuming you have conda already installed and your shell is properly configured, you can activate the base environment via
conda activate
You can also create a new environment, see manage-environments docs.
For more information than given below, see manage-pkgs docs.
In case of conda, after your environment is activated, you can then install a package via conda install <package name>, e.g. the package numpy
conda install numpy
In case of pip, after your environment is activated, you can then install a package via pip install <package name>, e.g. the package numpy
pip install numpy
I only do this if the package is not available via a conda channel.
If the package is also not available via pip, you can download the source and set the package up your self. Usually the package author describes how to set up his/her package.
Thanks Stefan for the suggestion! I struggled a bit because although conda was "already installed", my shell was indeed not "properly configured." I am writing here my solution because it may be a recurring theme for macOS users and had an easy fix.
Starting with macOS Catalina, macOS uses zsh and not bash as the default shell, and so calling conda on zsh had no effect. The error message was: -zsh: conda: command not found. I solved this by changing the default shell to bash by running the following command: chsh -s /bin/bash.
Now that the shell and conda are properly configured, I managed to use conda activate as you suggested Stefan.
Finally, the package pyLDAvis could not be installed by conda install pyldavis but was installed with pip install pyldavis.
Solved!

Trying to install a pip package in Anaconda

I'm trying to follow this tutorial:
https://learn.microsoft.com/en-us/azure/machine-learning/service/tutorial-data-prep
As part of this I'm trying to do a pip install of azureml as it's not available on conda. However doing a pip install will by default install it to my default python install, and not my conda install.
So I tried following the steps here:
https://conda.io/docs/user-guide/tasks/manage-environments.html#using-pip-in-an-environment
However after following these steps I then launch Jupyter notebook after activating myenv, navigate to the notebook, and try and run:
import azureml.dataprep as dprep
But get the error: ModuleNotFoundError: No module named 'azureml'
Also - I cannot tell if myenv is active in the notebook. The kernel simply says python3.
Be careful, when using pip in anaconda, it is possible that you are mixing pip and pip3.
Run which pip3 to be sure you are using the version that correspond to the virtual environment.
If you are using python3 in the environment, then pip will typically be the correct version to use. Do not use pip3 in that case.
This problem has been documented elsewhere on the web. The problem is that Jupyter notebooks itself only launches in the root environment by default. The simplest solution to getting it to launch for your env (e.g. myenv) is to install Jupyter within your env first. So from the Anaconda command prompt:
activate myenv
pip install jupyter
jupyter
Ps. Use source activate myenv for non-windows machines

How do I automatically run on an environment with Spyder?

Sorry if I am unclear/this is a lame question, still very new to setting up my computer.
So I installed Python using Anaconda for work, and at work there are specific packages that are used internally. I used Anaconda Prompt to install these packages by creating an environment and installing internally used packages. I then check to see if the package is there.
In the Anaconda Prompt...
conda create --name environment_name python = 3.4
activate environment_name
pip install <internal package> --upgrade
pip list
However, when I try to import a package on Spyder, it does not recognize the package. Is there a way for Spyder to run code on an environment that I specify? I would like the environment to run automatically on any file that I run using Spyder, being able to pull the packages that I installed on Anaconda Prompt

Categories

Resources