简体   繁体   English

Powershell中的Django-Admin.py

[英]Django-Admin.py in Powershell

I think I'm encountering a weird bug in Windows 8.1 trying to use django-admin.py (and any script really) in Powershell. 我想在Windows 8.1中尝试在Powershell中使用django-admin.py (以及任何脚本)时遇到一个奇怪的错误。 I've successfully installed Python 2.7.6, and have added C:\\Python27\\ and C:\\Python27\\Scripts to my path. 我已经成功安装了Python 2.7.6,并将C:\\Python27\\C:\\Python27\\Scripts到了我的路径。

When I try to use django-admin.py or python django-admin.py in Powershell, I get a file not found error. 当我尝试在Powershell中使用django-admin.pypython django-admin.py时,出现文件找不到错误。

Interestingly, when I use Command Prompt, I am able to use django-admin.py , even without the python prefix. 有趣的是,当我使用命令提示符 ,即使没有python前缀,我也可以使用django-admin.py

To execute scripts in Powershell, you need to set the execution policy to something other than restricted. 要在Powershell中执行脚本,您需要将执行策略设置为非受限策略。 For example: 例如:

Set-ExecutionPolicy RemoteSigned

This should allow general scripts (like .ps1 files) to be run. 这应该允许运行常规脚本(如.ps1文件)。 I still had problems running python files from the path so I added .py files to the PATHEXT variable. 我仍然无法从路径运行python文件,因此我将.py文件添加到PATHEXT变量中。 In Powershell: 在Powershell中:

$env:PATHEXT += ";.py"

I don't think this is permanent, so you may need to add it to your profile or change the environmental variables from the Advanced System Settings. 我认为这不是永久性的,因此您可能需要将其添加到配置文件中或从“高级系统设置”中更改环境变量。 This fixed the problem for me. 这为我解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM