简体   繁体   English

在Python Spyder中打开一个函数,就像我在MATLAB中一样

[英]Open a function in Python Spyder, like I do with MATLAB

In MATLAB, there I can place the cursor on a function name and press Ctrl + D , the file containing the function will automatically open. 在MATLAB中,我可以将光标放在函数名称上并按Ctrl + D ,包含该函数的文件将自动打开。 Is there any way I can do something similar with Python, within the Spyder IDE? 在Spyder IDE中,有什么方法可以用Python做类似的事情吗?

In Spyder you can jump to the definition of a function (or class) by holding CTRL and clicking on the function (or class) name/reference. 在Spyder中,您可以通过按住CTRL并单击函数(或类)名称/引用来跳转到函数(或类)的定义。 If that definition is in an other file, that file will be opened. 如果该定义位于其他文件中,则将打开该文件。

Ctrl + Leftclick 按Ctrl +左键单击

EDIT as commented by @pwagner 编辑由@pwagner评论

Rightclick -> Goto Definition 右键单击 - >转到定义

and

Ctrl + G Ctrl + G.

also work 也工作

Altough the answer given above is correct, it didn't work for me. 尽管上面给出的答案是正确的,但它对我不起作用。 Here is what I ended up doing: 这是我最终做的事情:

With the help of this post , I figured out that my Ubuntu 14.04 was missing some python packages for spyder to work properly. 这篇文章的帮助下,我发现我的Ubuntu 14.04缺少一些python包,以便spyder正常工作。

Go to Help -> Optional Dependencies and check which of the packages are missing or not in the required version. 转到Help -> Optional Dependencies并检查所需版本中缺少哪些软件包。 Copy to clipboard the list and paste it into an editor and store the file as requirements.txt . 将列表复制到剪贴板并将其粘贴到编辑器中,并将文件存储为requirements.txt Edit the file such that the list or required packages has the following format 编辑文件,使列表或所需的包具有以下格式

jedi==0.8.1
pep8==0.6
psutil==0.3
pyflakes==0.5.0
pylint==0.25
rope==0.9.2
sympy==0.7.3

Now do 现在做

sudo pip install -r requirements.txt

on that file. 在那个文件上。 Restart spyder. 重启spyder。 It should work now! 它现在应该工作!

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

相关问题 我如何像在spyder中一样在visual studio中激活交互式python帮助 - how do I activate interactive python help in visual studio like in spyder 像Matlab这样的python中的interp函数 - interp function in python like matlab 如何在 Python 中使用 Spyder 进行高效调试? - How do I debug efficiently with Spyder in Python? 如何像 Matlab 的 parfor 一样并行化 Python 中的 for 循环? - How do I parallelize for a for loop in Python like Matlab's parfor? Python open()函数在Spyder中不起作用,但在具有相同解释器的终端中起作用 - Python open() function not working in Spyder but working in the terminal with the same interpreter 如何摆脱 Spyder 上的这种开闭功能 - How do I get rid of this open-close feature on Spyder 如何使用Python正则表达式匹配MATLAB的函数语法? - How do I use a Python regex to match the function syntax of MATLAB? MATLAB 中的 mrdivide function:它在做什么,在 Python 中我该怎么做? - mrdivide function in MATLAB: what is it doing, and how can I do it in Python? Python中是否有一个View函数来旋转Matlab中的绘图? - Is there a View function in Python to rotate plots like in Matlab? Matlab的python中的矢量化sprintf函数 - Matlab's vectorized sprintf like function in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM