Package in pypi not installable by pip - python

Why can't I use
$ sudo pip install facebook-python-sdk
even with facebook-python-sdk package in pypi?
log: http://dpaste.com/hold/589044/

Not sure what's going on there, but you can use pip to install from the github repo:
pip install git+https://github.com/facebook/python-sdk.git\#egg=facebook-python-sdk
I usually use pip install -e which makes pip symlink the package for you, so you can edit the repo, update it etc, and get the latest changes without having to pip install again.

Related

Force uninstall of the package pip

I'm sorry if this is a repeat question, but whenever I search force uninstall of pip I get something like a pip uninstall command. What I want is a way to uninstall the package pip (and reinstall). when I run python3 -m pip uninstall pip setuptools in a conda enviroment I get this error:
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pip'. No files were found to uninstall.
Found existing installation: setuptools 45.2.0
Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'setuptools'. No files were found to uninstall.
I also get the same error in the base enviroment when I run /usr/lib/python3 -m pip uninstall pip setuptools.
However when I'm outside of a virtual enviroment (base) and I just run python3 -m pip uninstall pip setuptools, I get:
/home/cameron/anaconda3/bin/python3: No module named pip
I could just remove the file but I want to avoid if that would be problematic.
The problematic thing is I can still install things with pip in my base enviroment but I can't call python programs in my virtual enviroments anymore nor install new ones with pip (perhaps able to with conda) since it defaults to the packages installed with this pip even in a venv.
this should remove pip from your active conda environment
conda uninstall pip --force
I was finally able to remove with sudo apt-get purge python3-pip

pip install package with --user and without --user, now I want to uninstall package installed without --user

First, I run
pip install virtualenv
and later, I run
pip install --user virtualenv
So, this is what I have now
$ which -a virtualenv
/Users/admin/.local/bin/virtualenv
/usr/local/bin/virtualenv
This is my default virtualenv
/Users/admin/.local/bin/virtualenv
Now I want to uninstall, this,
/usr/local/bin/virtualenv
What should I do?
Thanks!
I tried
pip uninstall virtualenv
It removed /usr/local/bin/virtualenv, the system wide package.
The package I installed using --user flag, which cannot be uninstalled.
I just manually removed the folder.
See this thread.
How to uninstall a package installed with pip install --user

How can I revert changes done to python packages?

I'm debugging an issue on a staging, and I've added a bunch of logging statements to a 3rd party package. Once I'm done with that, I'd like to get them back to their original state. In ruby, I could do a gem pristine lib_name and that would restore the lib to it's original source code.
It might be relevant to mention that I'm modifying code that was installed with sudo pip install some_pkg.
What's the usual way of reverting any changes done to a lib?
On Linux:
Just type the following command in a terminal (with pip, pip2 or pip3, accordingly to the Python version you're targetting):
sudo -H pip install --upgrade --force-reinstall some_pkg
On Windows:
Open an admin terminal, and run the following command (ditto):
pip install --upgrade --force-reinstall some_pkg
Try this
pip install -r requirements.txt --force --upgrade
I suppose you have one "requriemnt.txt" file which you want to revert back packages to:
#remove all currently installed packages
pip freeze > remove.txt
pip uninstall -r remove.txt
#re-insatll all packages
pip install -r requriement.txt
This ensures that you also remove all unwanted packages

Upgrade pip in Amazon Linux

I wanted to deploy my Python app on Amazon Linux AMI 2015.09.1, which has Python2.7 (default) and pip (6.1.1). Then, I upgraded the pip using the command:
sudo pip install -U pip
However, it seemed broken, and showed the message when I tried to install packages:
pkg_resources.DistributionNotFound: pip==6.1.1
I found out that pip remove the previous files located in /usr/bin/, and installed the new one in /usr/local/bin. Thus, I tried to specify the location by using the command:
sudo pip install -U --install-option="--prefix='/usr/bin'" pip
Nevertheless, it still installed the new one in /usr/local/bin. In addition to that, pip could not work well with sudo although it successfully installed. The error message :
sudo: pip2.7: command not found
Is there a way to properly manage pip?
Try:
sudo which pip
This may reveal something like 'no pip in ($PATH)'.
If that is the case, you can then do:
which pip
Which will give you a path like /usr/local/bin/pip.
Copy + paste the path to pip to the sbin folder by running: sudo cp /usr/local/bin/pip /usr/sbin/
This will allow you to run sudo pip without any errors.
Struggled with this for a while. Here's what I've found:
ec2_user finds the pip executable, but has a module import error due to other having no read/execute permissions on the pip folders in the /usr/local/lib/python2.7/site-packages folder. This is actually okay, since in most cases, pip installs fail when not run as root anyway.
sudo cannot find pip.
Entering root with sudo su - allows pip to be run without issue.
The reason sudo pip stops working after the upgrade, is because the executable (or symbolic link) is removed from /usr/bin. However, what remains is a file called pip-27, which contains the following:
#!/usr/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==6.1.1','console_scripts','pip2.7'
__requires__ = 'pip==6.1.1'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==6.1.1', 'console_scripts', 'pip2.7')()
)
So, that's where our error comes from, as the upgrade clearly doesn't clean this file up. Not entirely clear on where the name translation from pip to pip-2.7 occurs.
As mentioned in another answer, pip now exists in /usr/local/bin after the upgrade, which is no longer in the sudo secure path. You can add this path to the secure_path variable by running sudo visudo. Another alternative, if you'd prefer to not add that path to your secure_path is to make a symbolic link to the new pip executable in /usr/bin.
The problem is partly answered by your question. The Amazon AMI doesn't consider /usr/local/bin to be part of the root account's PATH. You can fix this by updating the root account's ~/.bashrc to include it.
Something like this...
export PATH=$PATH:/usr/local/bin
After struggling with this for hours and reading comments
which pip gave /usr/bin/pip , but the actual pip was located at /usr/local/bin/pip due to pip upgrade and clean up was not complete
So removing the pip in /usr/bin/
sudo rm /usr/bin/pip
and also adding the new pip to your export path
vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/bin
exit terminal, and login back
which pip should give /usr/local/bin/pip
pip install --upgrade pip
This works for me
sudo /usr/local/bin/pip install --upgrade pip
To add to angelokh
sudo `which pip` install --upgrade pip
I think the best strategy in this case is to manage pip is as part of a virtual environment using virtualenv rather than messing with the system-level version.
If you're OK with that, here's the basic idea:
Install the version of virtualenv packaged with the version of pip you are looking to upgrade to to the system-level pip (e.g. virtualenv==15.1.0 comes with pip==9.0.1):
$ sudo pip install -U virtualenv==15.1.0
You are using pip version 6.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting virtualenv==15.1.0
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 135kB/s
Installing collected packages: virtualenv
Found existing installation: virtualenv 12.0.7
Uninstalling virtualenv-12.0.7:
Successfully uninstalled virtualenv-12.0.7
Successfully installed virtualenv-15.1.0
I used the virtualenv release notes to find out which version of pip corresponds to which version of virtualenv.
Create the virtual environment:
$ virtualenv myenv
New python executable in /home/ec2-user/myenv/bin/python2.7
Also creating executable in /home/ec2-user/myenv/bin/python
Installing setuptools, pip, wheel...done.
Activate the virtual environment and confirm the version and location of the upgraded pip:
$ source myenv/bin/activate
(myenv) $ pip -V
pip 9.0.1 from /home/ec2-user/myenv/local/lib/python2.7/dist-packages (python 2.7)
(myenv) $ which pip
~/myenv/bin/pip
This should allow you to install packages to this virtualenv using the pip version of your choice, without the need for sudo.
I think you've didn't installed the pythonXX-pip package.
I've upgraded mine straight to Python3.4, these commands works for me.
sudo su
yum install python34
yum install python34-pip

How to download and install the pcapy package with pip?

I know that in order to install a package I need to execute:
sudo pip install package_name
But how can I know what is the name of package - I should give as an argument.
I found in pypi a package I want to install - pcapy:
https://pypi.python.org/pypi/pcapy/0.10.3
I tried:
sudo pip install pcapy
It didn't work...
What is the right way to install this package?
Thank you very much!
That package isn't in the PyPI. There's a page, but the source code is hosted elsewhere for some reason (this is the first time I've seen it):
Ubuntu has a (probably old) package:
$ sudo apt-get install python-pcapy
You can also build it from source:
$ sudo pip install "http://corelabs.coresecurity.com/index.php?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-0.10.8.tar.gz"

Categories