Windows 7 Python 安装:使用完整命令,但“file.py --version"返回“无法加载 Python dll"; [英] Windows 7 Python installation: Works with full command, but "file.py --version" returns "Could not load Python dll"

查看:24
本文介绍了Windows 7 Python 安装:使用完整命令,但“file.py --version"返回“无法加载 Python dll";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是这个问题的后续:成功执行 Django python 命令的*唯一*方法是使用python ...PATH...django-admin.py [options]".为什么不能减少?

我可以成功运行一个命令,比如 django-admin.py,只要我在它前面加上 both python 和 py 文件的完全限定路径.例如,这工作正常:

python c:\applications\programming\python_341\Scripts\django-admin.py startproject mysite

但以下均无效(请参阅上一个问题以获取具体答复):

  • django-admin.py startproject mysite
  • python django-admin.py startproject mysite
  • c:\applications\programming\python_341\Scripts\django-admin.py startproject mysite

最令人担忧的是我什么时候跑步,因为 建议,这个:

django-admin.py --version

它以

响应

无法加载 Python dll

老实说,我不知道它应该回应什么,但我猜这不是它.

我今天已经卸载、重新启动计算机并重新安装 Python(以及 pip freeze 列出的所有内容)3 次.

这是我需要担心的事情吗?我能做些什么来修复它?

仅供参考:启动 Python shell 会在顶部打印:

Python 3.4.1(v3.4.1:c0e311e010fc,2014 年 5 月 18 日,10:38:22)[MSC v.1600 32 位(英特尔)] 在 win32 上

<小时>

在遵循@Bo102010 的建议后更新了路径:

C:\applications\programming\python_341\DLLs;C:\applications\programming\python_341\;C:\applications\programming\python_341\Scripts;C:\应用程序\编程\;.;C:\Program Files\Common Files\ArcSoft\Bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Windows Live\Shared;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\system32;C:\applications\programming\apache-ant-1.8.1\bin;C:\applications\programming\apache-maven-3.1.1\bin;C:\applications\programming\jdk_7_51\bin;C:\应用程序\视频\quicktime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\applications\programming\apache-maven-3.2.2\bin;C:\应用程序\实用程序\gpg4win\pub

<小时><块引用>

如果你在你的驱动器中搜索 django-admin.py,你能找到那个吗?– Bo102010

C:\applications\programming\python_341\Scripts\django-admin.py(这是PATH上的那个,这个在源代码中有windows路径,另一个有unix/linux 路径):

#!C:\applications\programming\python_341\python.exe从 django.core 导入管理如果 __name__ == "__main__":management.execute_from_command_line()

C:\applications\programming\python_341\Lib\site-packages\django\bin\django-admin.py:

#!/usr/bin/env python从 django.core 导入管理如果 __name__ == "__main__":management.execute_from_command_line()

我确认这两个文件都是由 Django 安装的.我卸载了,两个都消失了.

解决方案

无法加载 Python dll 消息来自 获取命令控制台 shell.

它似乎不尊重 .py 文件的 Windows 文件关联.

对于未来遇到此问题的人:

  1. 如果您使用的是 TCC,请尝试使用 cmd.exe 而不是 TCC
  2. 确保 Windows 对 .py 文件具有正确的文件关联.对于 Windows Vista+,请尝试使用 默认程序编辑器 进行验证.

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:\applications\programming\python_341\Scripts\django-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:\applications\programming\python_341\Scripts\django-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:\applications\programming\python_341\DLLs;
C:\applications\programming\python_341\;
C:\applications\programming\python_341\Scripts;
C:\applications\programming\;
.;
C:\Program Files\Common Files\ArcSoft\Bin;
C:\Program Files\Common Files\Microsoft Shared\Windows Live;
C:\Program Files\Windows Live\Shared;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\system32;
C:\applications\programming\apache-ant-1.8.1\bin;
C:\applications\programming\apache-maven-3.1.1\bin;
C:\applications\programming\jdk_7_51\bin;
C:\applications\video\quicktime\QTSystem\;
C:\Program Files\TortoiseSVN\bin;
C:\applications\programming\apache-maven-3.2.2\bin;
C:\applications\utilities\gpg4win\pub


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

C:\applications\programming\python_341\Scripts\django-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:\applications\programming\python_341\python.exe
from django.core import management

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

C:\applications\programming\python_341\Lib\site-packages\django\bin\django-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.

解决方案

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.

这篇关于Windows 7 Python 安装:使用完整命令,但“file.py --version"返回“无法加载 Python dll";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆