Closed mkane848 closed 8 years ago
Looks like this is an issue specific to Windows:
code = call(['python', 'django-admin.py', 'startproject', projectname, '.'])
If you're just testing and you don't care about reusability edit your u:\organice\env\lib\site-packages\organice\bin\organice_setup.py
directly.
The python executable must be in your PATH
. See the StackOverflow question for solutions otherwise.
On Unix this works because the django-admin.py
script is made executable using file permissions.
Alright, made the change to organice_setup and I'm now getting a different error.
Generating project example ...
python: can't open file 'django-admin.py': [Errno 2] No such file or directory
django-admin.py is in fact located in my env\Scripts\ folder
Can you try setting the path instead, i.e. restore the call
code as before (no python
call) and try as suggested in StackOverflow question 17836416? This looks like the appropriate approach.
My path is set at C:\Users\mkane\AppData\Local\Programs\Python\Python35-32\Scripts
. I've gotten DjangoCMS to run on this environment, if that helps at all
Alright, so django CMS' scripts are at the same location as django Organice' scripts? (Which django CMS commands do you execute that work?) If not, try to understand what's the difference. The problem must be there.
Let me know about your findings, so I can incorporate either some changes to the code or provide hints for Windows users in the documentation. Thank you!
@mkane848 Mike, if there is anything that you can share what solved your problem please let us know.
I actually didn't get around to solving the problem, just ended up going back to regular DjangoCMS. I'll keep messing with Organice to see if I can figure it out still
I believe the issue is with Windows. Even with the path set, I still have to copy the path to where my django-admin.py file is. So I believe the best tip to put in documentation for Windows users is that if your Path is properly set on Windows but it still can't find django-admin.py, go to line 123 in organice_setup.py and change it to:
code = call(['python', r"<path to virtualenv folder>\Scripts\django-admin.py", 'startproject', projectname, '.'])
Which allows the setup script to run properly to completion.
Thank you, @mkane848, for this helpful feedback!
I still think we should try to solve the problem. Editing the source code is not a solution. Our situation is especially odd, you'd have to go into the sources installed in your virtualenv's site-packages
, not nice.
If the PATH
environment variable is set correctly, but django-admin.py
is not found then something must be wrong with the environment. I suspect the call
function call results in a new environment which points to the wrong python binary, because the PATH
environment variable is not set correctly.
I've done a lucky 30-seconds googling (with duckduckgo) and found a hint on assoc and ftype. That could or could not be a helpful puzzle piece. (Actually, this could be used to solve the very first complaint on the command line, where the Windows cmd
interpreter complains that the .py
file is "not a valid Win32 application".)
Can you try printing the contents of the PATH
variable with the call
function? That should make it clear if I'm suspecting the right culprit.
EDIT: It's actually logical that you have to use the full path with the python
call. It's just a parameter to the Python interpreter. It's not even Windows' fault that python
doesn't find the django-admin.py
script, actually Windows does find the script as the first error trace above demonstrates, but it must be used as a command, i.e. as the first argument on the command line, not a parameter.
This is also discussed (and solved) in this StackOverflow question. Interestingly, the Django documentation is talking about a django-admin.exe
(NOTE: .exe) file. Maybe we should simply use django-admin
instead of django-admin.py
? This would find the .exe
on Windows, and the .py
script on Unixes.
@mkane848 can you try?
code = call(['django-admin', 'startproject', projectname, '.'])
This works on Linux, and will most probably work on your Windows system too. I'll change that in the current development version.
Confirming that it works on Windows. Nice catch with the .exe/.py switch!
Thank you for reporting the issue and your trouble shooting!
Following the documentation and calling "organice-setup example", I get:
I'm on Windows 10 and using Python 3.5