How to fix conda update conda permission error - linux

~$ conda update conda
Solving environment: done
## Package Plan ##
environment location: /home/david/anaconda3
added / updated specs:
- conda
The following packages will be UPDATED:
conda: 4.4.10-py36_0 --> 4.4.11-py36_0
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: failed
ERROR conda.core.link:_execute(481): An error occurred while uninstalling package 'defaults::conda-4.4.10-py36_0'.
PermissionError(13, 'Permission denied')
Attempting to roll back.
Rolling back transaction: done
PermissionError(13, 'Permission denied')
I was trying to update conda on virtualbox ubuntu 16.04 and this permission error came up. I tried sudo conda update conda but it returns sudo: conda: command not found. I'm not sure where to go from here.

I got the same error and solved it by this:
sudo env "PATH=$PATH" conda update conda

All conda commands must be run without super user privileges. That's why sudo conda command doesn't work.
You may have run conda installation bush file with super user privileges while installing. The user (david) running conda doesn't have write permissions to paths(/home/david/anaconda3) it needs to modify in the environment, then conda can't do anything. To solve this problem you need to change permissions to paths (/home/david/anaconda3).
To change permissions to paths (/home/user/anaconda3) using:
sudo chown -R user /home/user/anaconda3

I solved this problem by right clicking on Anaconda Prompt, selecting "Run As Administrator", and typing the command that I want to execute.
This problem arise if at installation time, we select an option install for all user anaconda. It can be solved as I mentioned above - run it as Administrator and type the conda commands for install, updating the packages.

It's Permission denied, So just sudo chown -R frazier:frazier /home/frazier/anaconda3
PS: change 'frazier' to your user name.

conda install numpy
{
Executing transaction: failed
ERROR conda.core.link:_execute(502): An error occurred while uninstalling package 'defaults::conda-4.5.4-py27_0'.
OSError(13, 'Permission denied')
Attempting to roll back.
Rolling back transaction: done
OSError(13, 'Permission denied')}
solution:
to change the permission to conda, use the command :
sudo chown -R nikhil /home/nikhil/miniconda
chown command changes the permission of miniconda to use sudo.
now you have the permisssion to access sudo..
now use:
conda update conda
now
Executing transaction: Done

You have installed Anaconda with sudo or root user. You need to install it with normal ubuntu/<Your username> user.
Remove or take backup of the already installed Anaconda (/home/<user>/anaconda3).
With normal mode install anaconda ( bash conda_installer_script ) .
Check .bashrc for this line and validate it.
export PATH="/home/<username>/anaconda3/bin:$PATH"
If not add it with proper anaconda path .
Reload .bashrc file and check conda is working by conda list command.
Now you can do conda update conda

I too had this error and resolved it by doing the following things - a little strange but worth a try.
1. Run as administrator
2. Run the code below to specifically update package in an environment -myenv
$conda install --name myenv numpy
3. For me the environment was running hence it was not updating, once I closed my running workbooks, and ran Point 1 and 2 .. it worked :)

if you have this error message during package installation in anaconda then follow the given step:
open the anaconda prompt by right click.
select the run as administrator.
type the command for install package.eg conda install numpy

Run Anaconda Prompt using "Run as Administrator" option and then
run the command -> conda update conda
Then go back to starting Anaconda Prompt as usual and I believe everything should be fine.
Also, don't forget to add Anaconda3 path to Environment variables.

Related

After installing conda packages, login name disappears from Linux terminal

After installing any conda package, login name disappears from Linux terminal. For reference please see screenshot.
Looks like you installed conda 22.9.0. Changes were made to the shell interface requiring a one-time re-initialization of conda:
conda init bash
After running the above command, you will need to restart your shell for the changes to take effect.
See: https://github.com/conda/conda/issues/11885

python installing bluepy to virtualenv

I'm a *nix noob. I'm on Ubuntu 16.04.
I'm trying to install bluepy to a virtualenv. It is currently installed under my user (not a virtualenv). When running pip freeze I see it listed under my user. When I activate the virtualenv and run pip freeze it does not show up. I tried to install it under the virtualenv using the following command: sudo pip3 install bluepy. It returns this:
The directory '/home/todd/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/todd/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
I'm not sure what to do. If responding please add explanations so I can learn something. Thanks!
EDIT:
This answer did not help solve my problem. It was tailored for a Mac OS, not Ubuntu.
pip install: Please check the permissions and owner of that directory

Cannot run jupyter notebook in Ubuntu

I have installed jupyter notebook using:
sudo pip3 install jupyter
It seemed to work but I got the error:
The directory '/home/user1/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user1/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag
When I run it:
jupyter notebook
I get the error:
Error executing Jupyter command 'notebook': [Errno 8] Exec format error
Try:
pip3 install jupyter --user
This will install jupyter to your home directory. This removes the ownership issue. In my case the installation directory is:
~/.local/lib/python3.6/site-packages.
I use Linux Mint, which is a fork of Ubuntu.

Buildozer initiation issue in Ubuntu as 'command not found'

I am trying to convert a kivy .py file into .apk using buildozer in ubuntu. I have been following this person's tutorial:
https://kivyspacegame.wordpress.com/2014/06/30/tutorial-how-to-build-python-for-android-with-ubuntu-and-buildozer/
However, I am stuck at the stage at
buildozer init
Resulting in error.
command not found
Similar issue is seen here https://groups.google.com/forum/#!topic/kivy-users/_uCnOC8fdPo. But it doesn't have a solution. I checked cython and buildozer installations using 'pip freeze" and going into python and type 'import cython' and 'import buildozer', they didn't give me any error message.
it is already an older thread but, try this, if you have the problem today either. Just simply tiping this in the terminal..
git clone https://github.com/kivy/buildozer
cd buildozer
python setup.py build
sudo pip install -e .
and now u can type->
buildozer init
etc..
p.s.
sorry for my English :D <3
These are the steps I tried to get out of it.
First uninstall buildozer :
pip3 uninstall buildozer
Then clone buildozer git :
git clone <link>https://github.com/kivy/buildozer.git</link>
cd git_directory_new_made
Now in terminal go to root :
sudo su
enter password:your password here
python3 setup.py install
Go out of terminal and then reopen it.

How do I remove/delete a virtualenv?

I created an environment with the following command: virtualenv venv --distribute
I cannot remove it with the following command: rmvirtualenv venv -
This is part of virtualenvwrapper as mentioned in answer below for virtualenvwrapper
I do an lson my current directory and I still see venv
The only way I can remove it seems to be: sudo rm -rf venv
Note that the environment is not active. I'm running Ubuntu 11.10. Any ideas? I've tried rebooting my system to no avail.
"The only way I can remove it seems to be: sudo rm -rf venv"
That's it! There is no command for deleting your virtual environment. Simply deactivate it and rid your application of its artifacts by recursively removing it.
Note that this is the same regardless of what kind of virtual environment you are using. virtualenv, venv, Anaconda environment, pyenv, pipenv are all based the same principle here.
Just to echo what #skytreader had previously commented, rmvirtualenv is a command provided by virtualenvwrapper, not virtualenv. Maybe you didn't have virtualenvwrapper installed?
See VirtualEnvWrapper Command Reference for more details.
Use rmvirtualenv
Remove an environment, in the $WORKON_HOME.
Syntax:
rmvirtualenv ENVNAME
You must use deactivate before removing the current environment.
$ rmvirtualenv my_env
Reference: http://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html
You can remove all the dependencies by recursively uninstalling all of them and then delete the venv.
Edit including Isaac Turner commentary
source venv/bin/activate
pip freeze > requirements.txt
pip uninstall -r requirements.txt -y
deactivate
rm -r venv/
If you are using pyenv, it is possible to delete your virtual environment:
$ pyenv virtualenv-delete <name>
Simply delete the virtual environment from the system:
rm -rf venv
(There's no special command for it)
from virtualenv's official document https://virtualenv.pypa.io/en/latest/user_guide.html
Removing an Environment
Removing a virtual environment is simply done by deactivating it and deleting the environment folder with all its contents:
(ENV)$ deactivate
$ rm -r /path/to/ENV
1. Remove the Python environment
There is no command to remove a virtualenv so you need to do that by hand, you will need to deactivate if you have it on and remove the folder:
deactivate
rm -rf <env path>
2. Create an env. with another Python version
When you create an environment the python uses the current version by default, so if you want another one you will need to specify at the moment you are creating it. To make and env. with Python 3.X called MyEnv just type:
python3.X -m venv MyEnv
Now to make with Python 2.X use virtualenv instead of venv:
python2.X -m virtualenv MyEnv
3. List all Python versions on my machine
If any of the previous lines of code didn't worked you probably don't have the specific version installed. First list all your versions with:
ls -ls /usr/bin/python*
If you didn't find it, install Python 3.X using apt-get:
sudo apt-get install python3.X
I used pyenv uninstall my_virt_env_name to delete the virual environment.
Note: I'm using pyenv-virtualenv installed through the install script.
The following command works for me.
rm -rf /path/to/virtualenv
If you are a Windows user and you are using conda to manage the environment in Anaconda prompt, you can do the following:
Make sure you deactivate the virtual environment or restart Anaconda Prompt. Use the following command to remove virtual environment:
$ conda env remove --name $MyEnvironmentName
Alternatively, you can go to the
C:\Users\USERNAME\AppData\Local\Continuum\anaconda3\envs\MYENVIRONMENTNAME
(that's the default file path) and delete the folder manually.
Actually requires two deletions.
The project folder which everyone in this thread already said you simply delete manually or using rm -r projectfoldername
But then you also need to delete the actual virtualenv located in macOS /Users/edison/.pyenv/versions/3.8.0/envs/myspecialenv.
You can do that by doing pyenv virtualenv-delete myspecialenv or manual removal.
if you are windows user, then it's in C:\Users\your_user_name\Envs. You can delete it from there.
Also try in command prompt rmvirtualenv environment name.
I tried with command prompt so it said deleted but it was still existed. So i manually delete it.
cd \environmentfolder_name\Scripts\deactivate.bat
deactivate is the command you are looking for. Like what has already been said, there is no command for deleting your virtual environment. Simply deactivate it!
If you're a windows user, you can also delete the environment by going to: C:/Users/username/Anaconda3/envs Here you can see a list of virtual environment and delete the one that you no longer need.
If you are using pyenv virtualenv < https://github.com/pyenv/pyenv > to centrally manage python versions and virtual environment the solution would be
pyenv uninstall some_env
(Assuming that you have set up your bash .szh profile correctly.)
The solution to this issue is also answered here:
https://github.com/pyenv/pyenv-virtualenv/issues/17
Hope this helps 👍🏻
Just use Anaconda Navigator to remove selected env.
It is possible that some resources will be activated, making it impossible to just delete the directory. All Python processes should be stopped in advance:
pkill -9 python
rm -rf venv
You can follow these steps to remove all the files associated with virtualenv and then reinstall the virtualenv again and using it
cd {python virtualenv folder}
find {broken virtualenv}/ -type l ## to list out all the links
deactivate ## deactivate if virtualenv is active
find {broken virtualenv}/ -type l -delete ## to delete the broken links
virtualenv {broken virtualenv} --python=python3 ## recreate links to OS's python
workon {broken virtualenv} ## activate & workon the fixed virtualenv
pip3 install ... {other packages required for the project}
For the new versions do:
conda deactivate
conda env remove -n env_name
step 1: delete virtualenv virtualenvwrapper by copy and paste the following command below:
$ sudo pip uninstall virtualenv virtualenvwrapper
step 2: go to .bashrc and delete all virtualenv and virtualenvwrapper
open terminal:
$ sudo nano .bashrc
scroll down and you will see the code bellow then delete it.
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
next, source the .bashrc:
$ source ~/.bashrc
FINAL steps: without terminal/shell go to /home and find .virtualenv (I forgot the name so if your find similar to .virtualenv or .venv just delete it. That will work.

Resources