Why won't pip install anything? - python-2.7

Whenever I try to pip install anything in my virtualenvs I am told it is Downloading/Unpacking. My terminal then stays on that line indefinitely. The longest I have left this running was 2 hours (trying to install iPython) without success.
Most recently, I tried installing django in one virtualenv using pip. Once it said Downloading/Unpacking I created another virtualenv in another terminal window and used easy-install to install django and mezzanine. Both installed with their dependencies before there was any movement on the terminal using pip. I left the pip window running for an hour before giving up. I have tried pip install, pip install -v --use-mirrors and their sudo equivalents without much change in the results (-v --use-mirrors spews out a list of urls before stalling at Downloading/Unpacking).
I am using Python 2.7 on Ubuntu 12.04.1 64-bit. I use Virtuanlenvwrapper to create and manage my virtualenvs, if that helps.
I can't find any references to other people having this problem so I expect it's a mistake of mine. Does anyone have any idea what I'm doing wrong?

Following #HugoTavares's suggestion I found I needed to install python-dev. I don't know why this helped but it seems to have solved this particular problem. I'm putting this answer on for now but Hugo, if you read this, please post an identical one and I'll remove acceptance on this and accept yours, since you deserve the credit.

Related

Difference pip/pipenv

I guess it's going to be obvious in a few seconds but I am fairly new to web development.
I am learning how to use Django and I encountered an issue with allauth after having installed it through pipenv and tried to migrate. I got a lovely ModuleNotFoundError: No module named 'allauth'. As I said, I installed it through pipenv and I could see allauth in my .venv/Lib/site-packages file. I have my virtual environment set and activated.
A quick research and thanks to this answer, I solved my issue by "reinstalling" it with pip install allauth, and my migration is now working fine.
What I don't understand is, wasn't it already installed when I did pipenv install allauth, do I need to install everything once with pipenv to get the Pipfile & Pipfile.lock updated and then also install it through pip...?
Obviously, I don't fully understand the difference between pipenv & pip, if some charitable soul would be kind enough to explain this to me, I'd greatly appreciate it :)
Edit: I saw this thread already but either way I am stupid or whatever but it still doesn't make much sense to me.
so, you said pip install allauth fixed the issue for you. But that might be because it installed the package GLOBALLY, and you definitely don't wanna do that.
Rather, you should try reinstalling using pipenv itself. It has happened to me before and got fixed this way.
In case if that didn't work, try removing and re-setuping the virtual env -
pipenv --rm
pipenv shell
pipenv install
Difference between PIP & PIPENV
In a very layman's language,
pip is a package installing manager itself used to install other packages like panda, pillow, django, virtualenv... etc
pipenv, on the other hand, is a package created to simplifies the burden of using virtualenv and pip seperately. (I'm assuming you know how virtualenv works)
You don't need pipenv if you are using virtualenv with pip. But I would anyday recommend to use pipenv because who wants pain right?
To understand more, I think you should also research (google) VIRTUALENV vs PIPENV. That'll definitely help.
Reference URL
https://pypi.org/project/pipenv/#:~:text=You%20no%20longer%20need%20to%20use%20pip%20and%20virtualenv%20separately.%20They%20work%20together

In Windows 10, pip import error: cannot import name main after installing pipenv

I am trying to use pipenv as well as pip and having some issues. I installed pipenv using pip. I installed pipenv using pip. Then I went back and tried to run pip -v and got the following: ImportError: cannot import name main. I have seen this question answered for Linux and Mac, but I cannot use sudo or which commands; I am on Windows 10 using the CMD console. In my scripts folder, I see pip, pip2.7, and pip2. I cannot remember which one was my system pip. I know I need to maybe uninstall and reinstall (I have already tried to upgrade, but of course, without pip running you can't upgrade pip). I don't want to make more of a mess, so I wanted to ask how to resolve this in the CMD console on Windows.
Apparently, when I installed pipenv, it changed the system pip version that I was previously using. For some reason, all of the answers I found were using Linux or Mac, but here is how I resolved it. Simply open your command prompt and type:
$python -m pip uninstall pip
Then, test that you still have your old version installed by typing:
$pip -V
This showed me that I had gone from using pip version 18 back to using version 8.1.1. You should then be able to proceed to other tasks using pip.

Cannot user easy_install or install pip

I am a noob here. Because I need to use Python 2.7 for work, I created another user login and tried to re-setup my dev environment. I have reinstalled python 2.7 using brew but I couldn't get easy_install or work and my system cannot find where pip is. Much frustration here, hope someone can help!
I have already tried to install pip and the system still cannot find it:

Unable to get these to cooperate: mysql-python + virtualenv + percona + centos6

I've gone through many threads related to installing mysql-python in a virtualenv, including those specific to users of Percona. None have solved my problem thus far.
With Percona, it is normal to get a long error on pip install MySQL-python in the virtualenv that ultimately says EnvironmentError: mysql_config not found. One method to remedy this is yum install mysql-devel, which I've done. I can actually get mysql-python to install properly outside of the virtualenv via yum.
I'm getting the error in the virtualenv only - it uses Python 2.7.9, wheareas 2.6.6 is what comes with Centos.
Also, with MySQL-python installed via yum it will import to the OS's python interpreter, but will not import into the virtualenv's python interpreter.
To clarify, I only installed mysql-python via yum to see whether or not it would work that way. I would prefer it be by pip, in the environment only.
What am I missing here? As far as I'm aware it should work - considering it will work outside of virtualenv.
Found the solution!
I think it was improper of my to install mysql-devel in the first place, so I went ahead and uninstalled it.
Instead, I used a packaged supplied by Percona - Percona-Server-devel-55
yum install Percona-Server-devel-55 and the problem is solved!

Some Confusion about easy_install without Root Access

Preface
I am so new to ssh/unix protocols that I hope I don't offend anybody.
Context
I am using the cores at my university, and do not have root access. Thus, when I install python modules, I resort to the answer on these two related stack overflow posts:
1) How to install python modules without root access?
2) How to install python packages without root privileges?
In the second post, Col Panic highly recommends getting pip or easy_install on the cores, and if they are not already there, 'you should politely ask the admins to add it, explaining the benefit to them (they won't be bothered anymore by requests for individual packages)."
Following that piece of advice, I request that the admin put easy_install on all the cores. They did and after some proverbial futzing around with export, PATH and PYTHONPATH, I was able to get numpy and scipy on the cores and import them into iPython environment.
Unfortunately, there was some problems with matplotlib related to this question: ImportError: No module named backend_tkagg
I thought I could just ignore this problem related to SUSE by pickling everything and then plotting it on my laptop.
My Problem
I really do need NetworkX. I wrote down some notes on all the small intricacies that I used to install the other packages my last go, but failed this time around. Maybe I am forgetting something that I did last time?
nemo01.65$ easy_install --prefix=/u/walnut/h1/grad/cmarshak/xdrive/xpylocal networkx
TEST FAILED: /u/walnut/h1/grad/cmarshak/xdrive/xpylocal/lib/python3.3/site-packages does
NOT support .pth files
error: bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/u/walnut/h1/grad/cmarshak/xdrive/xpylocal/lib/python3.3/site-packages
and your PYTHONPATH environment variable currently contains:
'/u/walnut/h1/grad/cmarshak/xdrive/xpylocal/lib/python2.7/site-packages'
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
My Attemps to Fix This
I really do networkx otherwise I have to adjust a bunch of my code that I want to put on the clusters.
1) I typed in:
export PYTHONPATH=/u/walnut/h1/grad/cmarshak/xdrive/xpylocal/lib/python3.3/site-packages
into the bash environment. No luck...
2) I asked another grad for some help. He suggested I install pip via easy_install, which I did and then use:
pip install --user networkx
When I type in:
find ./local/lib/python2.7/site-packages/ | grep net
I get a ton of files that are all from the networkx library. Unfortunately, there is still some problems with dependencies.
THANK YOU IN ADVANCE FOR YOUR HELP. Really enjoy learning new things from your answers.
It looks like there are multiple versions of pip floating around (cf pip: dealing with multiple Python versions? ). Try installing pip using a specific version of easy_install. For example, this gave me a pip2.7
walnut.39$ easy_install-2.7 -U --user pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 1.5.6
Processing pip-1.5.6-py2.7.egg
pip 1.5.6 is already the active version in easy-install.pth
Installing pip script to /u/walnut/h1/grad/rcompton/.local/bin
Installing pip2.7 script to /u/walnut/h1/grad/rcompton/.local/bin
Installing pip2 script to /u/walnut/h1/grad/rcompton/.local/bin
Using /net/walnut/h1/grad/rcompton/.local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
walnut.40$
Then use pip2.7
walnut.40$ pip2.7 install --user networkx
Also, for non-root package installations, I've got the follow lines in my .bashrc:
export PYTHONPATH=$PYTHONPATH:$HOME/.local/lib/python2.7/site-packages
export PATH=$PATH:~/.local/bin