I'm trying to run an inherited Django project. I've set up a virtualenv and tried to pass in the requirements file via pip install -r requirements.txt. Everything seems to work. It tells me it's working in the correct virtualenv, and packages appear to install, e.g.:
Downloading/unpacking django-mediasync==2.2.0 (from -r requirements.txt (line 22))
Downloading django-mediasync-2.2.0.tar.gz
Running setup.py egg_info for package django-mediasync
But when I try to syncdb or runserver,
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x10f15e290>>
Traceback (most recent call last):
File "/Users/me/.virtualenvs/example/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 88, in inner_run
self.validate(display_num_errors=True)
File "/Users/me/.virtualenvs/example/lib/python2.7/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/Users/me/.virtualenvs/example/lib/python2.7/site-packages/django/core/management/validation.py", line 36, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Users/me/.virtualenvs/example/lib/python2.7/site-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/Users/me/.virtualenvs/example/lib/python2.7/site-packages/django/db/models/loading.py", line 61, in _populate
self.load_app(app_name, True)
File "/Users/me/.virtualenvs/example/lib/python2.7/site-packages/django/db/models/loading.py", line 76, in load_app
app_module = import_module(app_name)
File "/Users/me/.virtualenvs/example/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named mediasync
What's weird is that I install mediasync (or any other necessary packages) manually (pip install django-mediasync), the package can now be found.
What am I doing wrong? I don't want to have to install all of these packages manually.
I think when doing: pip install -r requirements.txt there was some error but you didn't notice. Basically the whole operation will stop at the time there is error.
So for example your requirements.txt have 4 packages like this:
A
B
C
D
If there is an error when installing B, 3 packages B, C and D will not be installed. It seems to me that there was an error with installation of one package in your requirements.txt and it didn't install django-mediasync at all.
If my hypothesis is right, please do pip install -r requirements.txt and check the last part of the traceback. If something fails, you will know exactly why.
Are you doing sudo pip install django-mediasync or sudo pip install -r requirements.txt? If so, it'll install it outside of the virtualenv. See How to install which programs requires "sudo" in virtualenv?.
Basically because your user should own the virtualenv directory, you don't need superuser privileges to install anything via pip. Do which pip and sudo which pip and you will see they are different.
The other possibility may be that your requirements.txt is not installing correctly. It may output lines like the line you mention, but apparently pip will scan all the packages in the requirements.txt before installing anything. If there is any error, it will abort the install for all packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With