如何让Spyder直接从Windows资源管理器打开python脚本(.py文件) [英] How to get Spyder to open python scripts (.py files) directly from Windows Explorer

查看:5397
本文介绍了如何让Spyder直接从Windows资源管理器打开python脚本(.py文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在Windows 7(Anaconda 3-2.4.0-Windows-x86_64)上安装了Anaconda发行版。与IDLE不同,我无法在Spyder IDE中右键单击并打开py文件。我将首先打开Spyder,然后导航到该文件或将其拖放到编辑器中。有没有办法直接从Widows Explorer打开编辑器中的文件?

I have recently installed the Anaconda distribution on Windows 7 (Anaconda 3-2.4.0-Windows-x86_64). Unlike IDLE, I can't right-click and open a py file in the Spyder IDE. I will have to open Spyder first and then navigate to the file or drag and drop it in the editor. Is there any way to open the file in the editor directly from Widows Explorer?

推荐答案

我遇到了类似问题的另一件我用的软件。

I have had a similar problem with another piece of software I use that I use.

我解决此问题的方法是将.py文件的文件关联设置为 C:\ Anaconda \Scripts\spider- script.py 通过打开对话框。如果您现在尝试通过双击打开 File.py ,您将收到错误,例如

My work around for this problem is to set the file association for .py files to C:\Anaconda\Scripts\spider-script.py via the Open with dialog. If you now try to open your File.py by double clicking you'll receive a error like


〜\ file.py不是有效的Win32应用程序。

~\file.py is not a valid Win32 application.

这可以通过编辑<$来解决c $ c> spyder-script.py 注册表项:

This can be resolved by editing the spyder-script.py registry key:

HKEY_USERS\S-1-5-21-3559708500-1520960832-86631148-1002\Software\Classes\Applications\spyder-script.py\shell\open\command

并替换默认值C:\ Anaconda \ Scripts\spyder-script.py%1 with C:\ Anaconda\python.exeC:\ Anaconda \ Scripts\spyder-script.py%1 。如果您的机器的路径不同,请使用此键的搜索功能,当然还要使用适合您的python安装的路径。 spyder-script.py 现在应该在python shell中执行。

and replacing the default value "C:\Anaconda\Scripts\spyder-script.py" %1 with "C:\Anaconda\python.exe" "C:\Anaconda\Scripts\spyder-script.py" %1. Use the search function for this key if the path isn't the same for your machine, and of course use the appropriate path for your python installation. spyder-script.py should now execute in a python shell.

来自ftype的文档字符串,

From the docstring of ftype,


...在打开的命令字符串中,%0或%1将替换为通过关联启动的文件名。

...Within an open command string, %0 or %1 are substituted with the file name being launched through the association.

这篇关于如何让Spyder直接从Windows资源管理器打开python脚本(.py文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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