Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
310 views
in Technique[技术] by (71.8m points)

Windows 7 Python installation: Works with full command, but "file.py --version" returns "Could not load Python dll"

This is a followup to this question: The *only* way to successfully execute Django python command is with "python ...PATH...django-admin.py [options]". Why can't it be reduced?

I can successfully run a command, say django-admin.py, as long as I prefix it with both python and the fully-qualified path to the py file. For example, this works fine:

python c:applicationsprogrammingpython_341Scriptsdjango-admin.py startproject mysite

But none of the following work (see the previous question for specific responses):

  • django-admin.py startproject mysite
  • python django-admin.py startproject mysite
  • c:applicationsprogrammingpython_341Scriptsdjango-admin.py startproject mysite

Most concerning is when I run, as suggested, this:

django-admin.py --version

It responds with

Could not load Python dll

I honestly don't know what it's supposed to respond with, but I'm guessing this ain't it.

I've uninstalled, restarted my computer, and reinstalled Python (as well as everything listed by pip freeze) three times today.

Is this something I need to worry about? What can I do to fix it?

FYI: Starting the Python shell prints this at the top:

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32


Updated PATH, after following @Bo102010's suggestion:

C:applicationsprogrammingpython_341DLLs;
C:applicationsprogrammingpython_341;
C:applicationsprogrammingpython_341Scripts;
C:applicationsprogramming;
.;
C:Program FilesCommon FilesArcSoftBin;
C:Program FilesCommon FilesMicrosoft SharedWindows Live;
C:Program FilesWindows LiveShared;
C:Windows;
C:WindowsSystem32Wbem;
C:WindowsSystem32WindowsPowerShellv1.0;
C:Windowssystem32;
C:applicationsprogrammingapache-ant-1.8.1in;
C:applicationsprogrammingapache-maven-3.1.1in;
C:applicationsprogrammingjdk_7_51in;
C:applicationsvideoquicktimeQTSystem;
C:Program FilesTortoiseSVNin;
C:applicationsprogrammingapache-maven-3.2.2in;
C:applicationsutilitiesgpg4winpub

If you search your drives for django-admin.py do you just find the one? – Bo102010

C:applicationsprogrammingpython_341Scriptsdjango-admin.py (this is the one on the PATH. This one has a windows path in the source code, the other has a unix/linux path):

#!C:applicationsprogrammingpython_341python.exe

from django.core import management

if __name__ == "__main__":
    management.execute_from_command_line()

C:applicationsprogrammingpython_341Libsite-packagesdjangoindjango-admin.py:

#!/usr/bin/env python
from django.core import management

if __name__ == "__main__":
    management.execute_from_command_line()

I confirmed that both of these files are installed by Django. I uninstalled and both disappeared.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Could not load Python dll message is coming from the Take Command Console shell.

It seems that it doesn't respect the Windows file associations for .py files.

For future people who have this problem:

  1. Try using cmd.exe instead of TCC, if you're using TCC
  2. Make sure Windows has the right file associations for .py files. For Windows Vista+ try using Default Programs Editor to verify.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...