Forums

Problems installing module via pip3

Trying to install 'django-admin-sortable' via pip

pip3 install django-admin-sortable2 --user

but it doesn't work — it seems to think it's installed, but it isn't. I get this logged:

Downloading/unpacking django-admin-sortable2
Downloading django-admin-sortable2-0.2.7.tar.gz (46kB): 46kB downloaded
Running setup.py (path:/tmp/pip_build_robertanthony/django-admin-sortable2/setup.py) egg_info for package django-admin-sortable2

warning: no previously-included files matching '*.pyc' found under directory '*'
Installing collected packages: django-admin-sortable2
Running setup.py install for django-admin-sortable2

warning: no previously-included files matching '*.pyc' found under directory '*'
Successfully installed django-admin-sortable2
Cleaning up...

Any clues? Thanks!

[edited by admin: formatting]

When you say "it seems to think it's installed, but it isn't", what are you doing to check if it's installed?

The directory and files it should create are not there and the functionality isn't present

Can I take a look at the file in your sandbox?

I'm happy for you to look anywhere — I confess I'm a newbie, very much so —

I was trying to get some sortable items on the backend — in my particular case it's 'PortfolioItem' — using Sortable2 from PiPy (https://pypi.python.org/pypi/django-admin-sortable2/0.2.2) —

I was able to get it working locally, but only by downloading the actual files from github and putting them in the right place — I don't believe I was able to get it to pip3 install locally either (again, as a newbie, my understanding of 'pip3 install' is following the recipe, typing in what I'm told, so it's hard for me to fix this, as I am only following instructions). Thanks!

It looks to me like it's installed OK (in /home/robertanthony/.local/lib/python3.3/site-packages).

From reading the docs, the next thing you need to do after you've installed it is to add the app to your settings.py. It doesn't look like you've done that?

http://django-admin-sortable2.readthedocs.org/en/latest/installation.html

Thanks —

I haven't done much to my code because I wanted to make sure it worked first — that it was installed properly.

When I did it on my local machine it wouldn't work properly after using pip3, and I had to download the zip file and move the folder 'adminsortable' into my project.

Then I put

from adminsortable.admin import SortableAdminMixin

and

class PortfolioItemAdmin(SortableAdminMixin,admin.ModelAdmin):
    ....

in admin.py. I also installed

    'adminsortable',

in settings.py

After that it worked locally.

If I install the app in settings.py on PA, will it work? The thing is (and I may be blind), I didn't see the 'adminsortable' directory, from which I can import the module(s) — it was seeing that this directory actually existed that I was looking for, otherwise I feared the import statement would fail…

Thanks for your help! As said, complete newbie in Python/Django (although have chops elsewhere).

If I install the app in settings.py on PA, will it work?

I think it probably will, but the only way to find out for sure is to try!

re: what's going on with importing code, Python looks in lots of different places when you tell it to import code -- it searches a series of folders from a list known as the "PYTHONPATH". Usually, the folder you're currently in is on the pythonpath, so that's why it works on your machine when you have the adminsortable folder and all its code inside your project.

But there are also some "standard" pythonpath places like the "site-packages" directory, which is where pip installs things to. either /usr/lib/python3.3/site-packages if you install packages system-wide, or /home/you/.local/lib/python3.3/site-packages when you use --user. So if you've pip installed some code and it's ended up in there, it should import just fine.

More info in the Official Python tutorial and in this guide

Of course! I'll try! I know how 'lazy' that sounded — simply I went through it locally, couldn't get it to work until I physically moved the files into my local space, that's the only reason I was uncertain and asked — I'll give it a shot and let you know…

Did as the docs (http://django-admin-sortable2.readthedocs.org/en/latest/usage.html) require, and I get no errors, but the functionality isn't present: the 'grabable' widgets in the admin to re-sort the items just aren't showing up. I tried a south migration after I changed the model and had initial data for my (new) ordering field, but south said nothing had changed. Hmmm.

I grant we may be into application-specific territory here, so I should sort it out, but not certain what I'm doing wrong — it worked locally.

UPDATE: ok, have been working — to the best of my limited knowledge — with south to try to update the DB, all seems to be in order. If you can help steer me on the right path, much appreciated.

Did you hit the "Reload" button on your web app tab after you made the change to settings.py?

The big green one -- several times.

Is there any simple way to "trace" if the mixin is being mixed-in? Total django newbie so not sure how to "debug" the problem.

Since it works locally for you, my guess would lean towards a static files issue. Check that you're actually serving the Javascript and other static files and that there are no errors in the browser when you load the page.

Brilliant! That seems to be it — I am getting 404's for these:

/static/adminsortable/js/plugins/admincompat.js
/static/adminsortable/js/libs/jquery.ui.core-1.10.3.js
/static/adminsortable/js/libs/jquery.ui.widget-1.10.3.js
/static/adminsortable/js/libs/jquery.ui.mouse-1.10.3.js
/static/adminsortable/js/libs/jquery.ui.sortable-1.10.3.js
/static/adminsortable/js/list-sortable.js

I understand I can simply track down and upload the jquery files —and I assume the others. But it goes back to the my question that started this thread: when I install something via pip3, where has it put them? In some other folder, but it needs to be in static for it to work on pythonanywhere?

UPDATE: Oh, I see, it's put them in

~/.local/lib/python3.3/site-packages/adminsortable/static

Added an additional static files entry to the web app tab with

URL = '/static/'

and

directory = ' /home/my_user_name/.local/lib/python3.3/site-packages/adminsortable/static'

and added

    directory = ' /home/my_user_name/.local/lib/python3.3/site-packages/adminsortable/static'

to STATICFILES_DIRS in settings.py and it seems to work fine now.

Why is it OK to have TWO urls == '/static/' in the web app tab? Or is it?

Thanks for the help!

what you probably want to do is run collectsatic:

https://docs.djangoproject.com/en/1.6/howto/static-files/