Pip doesn't install packages to activated virtualenv, ignores requirements.txt
Asked Answered
L

3

11

I am attempting to setup a development environment on my new dev machine at home. I have just installed Ubuntu and now I am attempting to clone a remote repo from our web-server and install its dependencies so I can begin work.

So far I have manually installed virtualenv and virtualenvwrapper from pypi and edited my bash.rc appropriately to source my virtualenvs when i start my terminal. I then cloned my repo to ~/projects/project-name/websitename.com. Then I used virtualenvwrapper to mkvirtualenv env-name from ~/projects/project-name/websitename.com. This reflects exactly the file-structure/setup of the web-server I am cloning from. So far so good.

I logged into the dev server and activate the virtualenv there and use pip freeze -l > req.txt to render a dependencies list and scp to my local machine. I activate the virtualenv on my local machine, navigate to the ~/projects/project-name/websitename.com and execute pip install -r path-to-req.txt and it runs through all of the dependencies as if nothing is wrong. However, when i attempt to manage.py syncdb i get an error about not finding core django packages. What the hell? So i figure somehow Django failed to install, i run pip install Django==1.5.1 and it completes successfully. I got to setup my site again and get another error about no module named django_extensions. Okay, what the hell with it, i just installed all of these packages with pip?!

So i pip freeze -l > test.txt and cat test.txt, what does it list? Django==1.5.1, the one package I just manually installed. Why isn't pip installing my dependencies from my specified list into my virtualenv? What am I messing up here?

-EDIT-------------

Which pip gives me the path to pip in my virtualenv

I have only 1 virtualenv and it is activated

Leatheroid answered 3/9, 2013 at 23:57 Comment(8)
Everything you are doing seems ok, try to debug with which pip.Lurleen
also try find ~/.virtualenvs -type d -iname "anypackage" to see if your required packages are installed or not. Also I recommend using https://gist.github.com/insin/1425703 which will give nice prompt about activated virtualenv in your bash.Valeda
running your command, the only packages in my virtualenv is the one I manually asked pip to install Django, all others processed by pip in the requirements file were ignored. I also somehow get a nice prompt indicating which virtualenv I have activated.Leatheroid
I can only recommend going through pip install -r again and see if any error is occuring in some specific package. You seem to do everything okay.Valeda
@sagarchalis Okay, i will try this shortly. As you said, something must be failing somewhere..Leatheroid
I recently encountered this problem on my Fedora Core 19 box.pip install -r requirements.txt wouldnt work for me. However, when I went through the list manually e.g. pip install Cython it worked fine.Lawtun
I encountered this symptom for Python 3 and found this page: github.com/pypa/virtualenv/issues/532 - it was solved by upgrading the installed version of virtualenv from 1.11 to 1.11.2Significancy
what is happening when you download the package manually and install using setup.pyCovarrubias
C
6

My usual workflow is to

pip freeze > someFile.txt

and then install with

pip install -r someFile.txt

So I'm certain that this should work just fine. Unfortunately I can't really tell you anything besides make sure to check that

  1. You really are in the virtualenv that you think you are in. Make sure to run

    workon yourVirtualEnvName
    

    to activate it just in case that matters.

  2. Make sure to check that pip is within your virtualenv.

    which pip
    

    gives me

    /path/to/home/.virtualenvs/myVirtEnv/bin/pip
    

Sorry I can't give you a more concrete answer. I have to do this semi-regularly and I've never had a problem with it skipping dependencies. Best of luck!

Cummins answered 4/9, 2013 at 0:12 Comment(2)
Huh, yeah, im running pip install -r someFile.txt and I even watch as it says it's downloading and installing but then the packages don't exist. For example it says: Downloading/unpacking django-extensions==1.1.1 (from -r req.txt (line 14)) Downloading django-extensions-1.1.1.tar.gz (149kB): 149kB downloaded Running setup.py egg_info for package django-extensions . But django-extensions doens't appear to be installed and still causes an error when called. It also doesn't appear when I pip freeze..Leatheroid
did you file a solution to this? I am having the exact same problem.Journalistic
M
3

Struggled with some variation of this issue not long ago; it ended up being my cluttered .bash_profile file.

Make sure you don't have anything that might mess up your virtualenv inside your .bash_profile/.bashrc, such as $VIRTUAL_ENV or $PYTHONHOME or $PYTHONPATH environment variables.

Matrilateral answered 16/9, 2014 at 13:14 Comment(0)
H
2

I know this is an old post, but I just encountered a similar problem. In my case the cause was that I was running the pip install command using sudo. This made the command run globally and the packages install in the global python path.

Hope that helps somebody.

Haleakala answered 3/10, 2015 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.