Accidentaly ran pip with sudo - python-3.x

After that I always get permission error when trying to install anything with pip. Is there any way to safely return everything back to normal?

You have run sudo -H pip install; sudo ran pip as root and pip changed ownership of some files and directories under your home dir. Take the files back:
sudo chown -R $USER $HOME

Related

Trying to Update Python 3 Using Homebrew

'''
(base) Kiefer's Macbook Pro:~ kiefergallant$ brew upgrade python3
Error: The following directories are not writable by your user:
/usr/local/share/man/man8
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/share/man/man8
And make sure that your user has write permission.
chmod u+w /usr/local/share/man/man8
(base) Kiefer's Macbook Pro:~ kiefergallant$
'''
Having a hard time updating python3 so I can use Tkinter

Error in creating virtualenv in ubuntu 16.04.2 LTS

Hello I am getting following error during virtualenv creation.
Here is the error:
$ mkvirtualenv cv
ERROR: virtualenvwrapper could not find /usr/local/bin/virtualenv in your path
Before this I was getting some weird message during the run of following commands:
sudo python get-pip.py
sudo pip install virtualenv virtualenvwrapper
Here is the weird message:
The directory '/home/myusername/.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/myusername/.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.
If I run this command sudo apt install virtualenv or virtualenvwrapper then I don't get the above weird message. but this don't help me to create virtualenv
python path is /usr/bin/python
Can anybody help me to figure out the issue by providing detailed command?
First, let's clear your "weird" message. It means that you've already used sudo -H before and sudo changed ownership for some of your files to root. Take the files back with the command
sudo chown -R myusername /home/myusername
(change myusername to your real login name; I used the name you've used in your question.)
After that upgrade pip and follow installation instructions for virtualenv and virtualenvwrapper:
sudo pip install -U pip setuptools virtualenv virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh

Running conda install as an admin on my ubuntu server, I get "Missing write permissions: /home/ubuntu/anaconda3"

I have installed Anaconda3 on my ubuntu server.
When I attempt to install or upgrade any package using conda, for example:
conda install numpy=1.11.0
(of course you cannot do "sudo conda")
I receive the following error:
Error: Missing write permissions in: /home/ubuntu/anaconda3
#
# You don't appear to have the necessary permissions to install packages
# into the install area '/home/ubuntu/anaconda3'.
# However you can clone this environment into your home directory and
# then make changes to it.
# This may be done using the command:
#
# $ conda create -n my_root --clone=/home/ubuntu/anaconda3
As #cel pointed out, providing the correct permissions is all that is necessary:
sudo chown -R ubuntu /home/ubuntu/anaconda3
sudo chmod -R +x /home/ubuntu/anaconda3

Installation Node v4.1 with NVM - Permission denied

I have to install Node v4.1.x on Ubuntu. I have already installed it but with the wrong version. This are the steps that I followed untill now:
Installation of nvm
sudo git clone https://github.com/creationix/nvm.git /opt/nvm
sudo mkdir /usr/local/nvm
sudo addgroup -system dev
sudo chown -R root:dev /usr/local/nvm
sudo chmod -R 775 /usr/local/nvm
sudo vim /etc/profile.d/nvm.sh
Editing of the file
export NVM_DIR=/usr/local/nvm
source /opt/nvm/nvm.sh
export NPM_CONFIG_PREFIX=/usr/local/node
export PATH="/usr/local/node/bin:$PATH"
Installation of Node
sudo mkdir /usr/local/node
sudo chown -R root:dev /usr/local/node
sudo chmod -R 775 /usr/local/node
nvm stable
For installing node v4.1.x this is what I want to do:
nvm ls //list of all version
nvm use 4.1.x //if I find the correct version in the list
The problem is that I can't make nvm ls because I get
mkdir: cannot create directory ‘/usr/local/nvm/alias’: Permission denied
What can I do?
I think you might change NVM_DIR to:
NVM_DIR="$HOME/.nvm"
The problem is that you've installed nvm using root user (with sudo). When executing nvm commands later:
nvm ls
nvm use 4.1.x
you do this without root and you get a permission denied.
Generally it is not recommended to install nvm using super user.
Please check this article for more details on how to install the version manager: http://rainsoft.io/install-node-like-a-boss-with-nvm/
This can also be because of issues during the curl installation.
Try reinstalling using
sudo apt-get install build-essential libssl-dev curl git-core
In your case issue because you gave 755 permission to the nvm folder. So it cant create folder without write permission as non root user.
Solution is you should be a root user or else give write permission for the folder to your particular user.
I too faced the same issue while installing nvm
ubuntu#ip-10-0-0-94:~$ nvm install 6.0.0
It reported as,
nvm install 6.0.0 mkdir: cannot create directory ‘/home/ubuntu/.nvm/bin’: Permission denied
grep: /home/ubuntu/.nvm/bin/node-v6.0.0-linux-x64/node-v6.0.0-linux-x64.tar.xz: No such file or directory Binary download failed
It with the 755 permission before.
drwxr-xr-x 4 root root 4096 Jun 23 07:44 .nvm/
Then I just gave write permission for it.
sudo chmod +w .nvm
Now issue was resolved and working fine.
ubuntu#ip-10-0-0-94:~$ nvm install 6.0.0
Downloading https://nodejs.org/dist/v6.0.0/node-v6.0.0-linux-x64.tar.xz...
######################################################################## 100.0%

Not able to install youtube-dl

I have tried almost everything I could find on google but could not install youtube-dl on Debian Mint.
Try 1
Installed and updated with following commands:
sudo apt-get install youtube-dl
sudo youtube-dl -U
But when tried
youtube-dl http://www.youtube.com/watch?v=dwYatpwrs8s
Then I got
Hi! We changed distribution method and now youtube-dl needs to update itself one more time.
This will only happen once. Simply press enter to go on. Sorry for the trouble!
From now on, get the binaries from http://rg3.github.io/youtube-dl/download.html, not from the git repository.
Then I went to http://rg3.github.io/youtube-dl/download.html and followed the installation instructions:
Try 2
sudo wget http://youtube-dl.org/downloads/2013.05.23/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl
Got the same error about the distribution change and new link.
Try 3
So I installed pip on my debian first and ran
sudo pip install --upgrade youtube_dl
But I am still getting same error and I have no idea what to do about it.
Just re-execute sudo youtube-dl -U and press Enter to update to the latest version. With your second try, you installed it a second time (to /usr/local/bin/ instead of /usr/bin) - you want only one.
Alternatively, simply uninstall youtube-dl with sudo apt-get remove -y youtube-dl. That should make the local version (/usr/local/bin/youtube-dl) the first one in your PATH again - if your PATH contains /usr/local/bin. If it doesn't, you can also just install youtube-dl to /usr/bin, with the following commands:
sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/bin/youtube-dl
sudo chmod a+x /usr/bin/youtube-dl
If you already install remove it:
sudo rm /usr/bin/youtube-dl
sudo apt-get remove -y youtube-dl
Try the following command
sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl
hash -r
I solved the issue with this:
https://github.com/ytdl-org/youtube-dl/issues/3908
Use the following commands to update:
sudo rm /usr/bin/youtube-dl # or apt-get remove -y youtube-dl
sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl

Resources