How can I see what packages were installed using `sudo pip install`? - python

I know that installing python packages using sudo pip install is bad a security risk. Unfortunately, I found this out after installing quite a few packages using sudo.
Is there a way to find out what python packages I installed using sudo pip install? The end goal being uninstallment and correctly re-installing them within a virtual environment.
I tried pip list to get information about the packages, but it only gave me their version. pip show <package name> gave me more information about an individual package such as where it is installed, but I don't know how to make use of that information.

any modules you installed with sudo will be owned by root, so you can open your shell/terminal, cd to site-packages directory & check the directories owner with ls -la, then any that has root in the owner column is the one you want to uninstall.

When you run sudo pip install, pip will install the package in your global site-packages directory.
So, to determine which packages you've installed with sudo pip install, you can navigate to your /site-packages directory.
The site-packages directory is a sub-directory of your python installation. For example, /Users/me/Library/Python/2.7/lib/python/site-packages.
This SO post has a more detailed discussion regarding how to find the site-packages directory.
Hope this helped!

try the following command: pip freeze

Related

Installing pip and numpy on Unix server without root access

I know this question has been asked and answered a number of times but none of those solutions have worked for me. I have installed Python 2.7 into a local directory and added it to my path. When I try to install numpy i get the following error:
ImportError: No module named setuptools
I cannot simply sudo apt-get install python-setuptools because i don't have root access.
I need to install numpy and ideally have pip working for future applications.
0) Try to install packages that are isolated to the current user, use the --user flag:
pip install --user SomeProject
1a) I agree with #Pi Marillion here, use an isolated conda environment if you don't have root access. This way you keep your path clean.
To install conda:
Since I don't know about your OS, go to https://docs.conda.io/en/latest/miniconda.html
After installation, update your conda (just in case):
conda update conda
To list the installed packages, you can do
conda list
You should see python installed. you can start an interpreter by typing python in the terminal.
There's conda cheat sheet that I found incredibly helpful:
https://docs.conda.io/projects/conda/en/latest/user-guide/cheatsheet.html
b) Now try installing via pip and I think you might need python 3.x for setuptools.
https://packaging.python.org/tutorials/installing-packages/#id13
2) If this does not work you can still try
https://packaging.python.org/guides/installing-stand-alone-command-line-tools/
Hope this helps :)
First try easy_install --user setuptools pip. If that doesn't work you need to install things manually.
Download setuptools-*.zip from https://pypi.org/project/setuptools/#files. Unzip the archive, cd into the new directory and run python2.7 setup.py install.
Then try pip install. If it still doesn't work reinstall pip: download get-pip.py and run python get-pip.py --user.

pip has to reinstall all packages in exported virtualenv

I have a question about python virtualenv. I get a virtualenv for a project with all packages required to run that project. But when i run it for the first time and it crash 'cause python has some requirements not satisfied. So i check if there is all packages inside:
virtualenv/lib/python2.7/site-packages/
and all packages required are inside.
But when i type:
pip list
packages doesn't shown. So i have to run:
pip install -r requirements.txt
pip downloads them again.
So my question is, why pip downloads and reinstall them again if they are installed yet ? And how i can force pip to reinstall all packages inside virtualenv ?
The problem was that all scripts inside the virtualenv were created on another pc with them paths. Indeed when i launched python or pip from virtualenv they ran from my global path 'cause couldn't find virtualenv script path and in particular pip shown my global packages.
Fixing directives path of all script inside virtualenb/bin/ to my real virtualenv path solved this issue.

bash: virtualenv: command not found "ON Linux"

I am using a form of Lubuntu called GalliumOS (optimized for Chromebooks). I installed pip using $ sudo apt-get install python-pip. I then used pip install --user virtualenv and pip install virtualenv, and then when I tried to subsequently use virtualenv venv I experienced the message bash: virtualenv: command not found.
Between the pip installs above, I used pip uninstall virtualenv to get back to square one. The error remained after a reinstall.
I read several other posts, but all of them seemed to deal with similar problems on MacOS. One that came close was installing python pip and virtualenv simultaneously. Since I had already installed pip, I didn't think that these quite applied to my issue. Why is pip install virtualenv not working this way on LUbuntu / GalliumOS?
Are you sure pip install is "failing"? To me, it sounds like the directory to which pip is installing modules on your machine is not in your PATH environment variable, so when virtualenv is installed, your computer has no idea where to find it when you just type in virtualenv.
Find where pip is installing things on your computer, and then check if the directory where the pyenv executable is placed is in your PATH variable (e.g. by doing echo $PATH to print your PATH variable). If it's not, you need to update your PATH variable by adding the following to your .bashrc or .bash_profile or etc.:
export PATH="PATH_TO_WHERE_PIP_PUTS_EXECUTABLES:$PATH"
What finally worked for me was this. I used
$ sudo apt-get install python-virtualenv.
I was then able to create a virtual environment using $ virtualenv venv.
I was seeking to avoid using $ sudo pip install virtualenv, because of admonitions in other posts to not do this, and agreed, because of experiences I'd had with subsequent difficulties when doing this.
pip install virtualenv
This command worked for me for. This problem that raised to me on Kali Linux.

pip installs packages, but doesn't mark them as executable, so python doesn't find them

I've been trying to use sudo to install python packages on a system that I am on the sudoers list, but don't have general root access (i.e. don't have the password for su). I can install packages, for example
sudo pip install django
however when I try and use them python simply claims not to have the package installed. Investigating the contents of /usr/lib/python it appears that other packages directories and .eggs have executable permissions for ugo, however the packages I install using sudo pip do not have this permission. Manually giving these files executable permissions fixes the problem, but that is laborious, particularly when pip installed several dependencies that I need to chase up.
Is this a known issue? What can I do about it? For the record this is a RHEL6.4 machine and I'm using pip 1.4.1.
You best bet is virtualenv Do your workaround to install the virtualenv.
sudo pip install virtualenv
Resources for virtualenv to get you started:
http://simononsoftware.com/virtualenv-tutorial/
http://www.virtualenv.org/en/latest/

Do I need to install python packages as root [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What are site-packages in python and can you install/use them if you aren’t root?
sudo apt-get install pip
creating /usr/local/lib/python2.7/dist-packages/boto
error: could not create '/usr/local/lib/python2.7/dist-packages/boto': Permission denied
pip install boto modifies the packages under /usr/local/bin in a Ubuntu box. Is this the way its supposed to work?
You can use the --user flag when installing python packages via pip or setup.py. This bypasses the need for root access by installing the package for the current user.
Some packages, such as virtualenv need to be installed by root but this is not a common requirement. It's always best to check package docs for installation requirements just in case.
See for more details:
How to manually install a pypi module without pip/easy_install?
How can I install packages in my $HOME folder with pip?
The only package you should install as root is virtualenv :
#pip install virtualenv
Then, you can work in a virtual environment as a normal user. It permits you to experiment without breaking everything in your system:
$virtualenv myproject
$cd myproject/
$./bin/pip install boto
Every python package you install will be installed in root directory, unless you use virtualenv. So you will need root access to modify the files in the installation folder. Try using sudo pip install boto.

Categories

Resources