Forums

Command Error: couldn't extract file --- Pinax project

Hello,

I know I can do this on my local machine without python anywhere, but I'm having trouble when doing this on python anywhere. I have a virtual machine, my web app is using python2.7. I'm following the directions from pinax: https://github.com/pinax/pinax-project-account

So I run this command: django-admin.py startproject --template=https://github.com/pinax/pinax-project-account/zipball/master mysite

When I try to start the project, I get this error: CommandError: couldn't extract file /tmp/django_project_template_e1ulrY_downl oad/master.html to /tmp/django_project_template_wU3ju6_extract: Path not a re cognized archive format: /tmp/django_project_template_e1ulrY_download/master. html

I do'nt really understand what this means. Can anyone explain?

Interesting. That sounds like something went wrong when downloading something. Could you copy/paste a bit more of the previous output in the console where you ran that?

This is all I ran:

mkvirtualenv sdtstevensenv
New python executable in sdtstevensenv/bin/python2.7
Also creating executable in sdtstevensenv/bin/python
Installing setuptools, pip, wheel...done.
pip install django Collecting django
Using cached Django-1.8.3-py2.py3-none-any.whl
Installing collected packages: django
Successfully installed django-1.8.3
django-admin.py startproject --template=https://gith ub.com/pinax/pinax-project-account/zipball/master sdtstevens
CommandError: couldn't extract file /tmp/django_project_template_hUBVNQ_downl oad/master.html to /tmp/django_project_template_3biG0D_extract: Path not a re cognized archive format: /tmp/django_project_template_hUBVNQ_download/master. html

I can't reproduce that error. I wonder if it could have been a temporary bug in the pinax-project template? Maybe try it again now?

Interesting! I think I've worked out what it is. Try these commands instead of the last one, I think it will fix the issue:

wget https://github.com/pinax/pinax-project-account/zipball/master
mv master master.zip
django-admin.py startproject --template=./master.zip sdtstevens

An explanation, in case you're interested -- free accounts on PythonAnywhere access the external Internet via a proxy. I think the proxy is breaking the information in the response from GitHub when the template is downloaded so that instead of being saved in a file called master.zip, it's saving it in a file called master.html. So when django-admin.py tries to unpack the file, it sees that it has the extension .html instead of .zip, complains and exits. The fix is just to download the file, rename it to the right name, and then run the admin command against the fixed file.

(The reason my colleague Harry couldn't reproduce the problem was that he was using a paid account, so the buggy proxy didn't get in the way.)

Hi giles, Running those commands worked! Thank you for your help with this, I really appreciate it :)

I actually have another similar question. I've added this downloaded project and I changed Allowed Hosts. However, when I load my site, I only get the default Hello World page from python anywhere. Why is that?

make sure you have commented/uncommented the correct lines in your wsgi file