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

杀马特。学长 韩版系。学妹 提交于 2019-12-06 06:22:14

问题


In MATLAB, there I can place the cursor on a function name and press Ctrl+D, the file containing the function will automatically open. Is there any way I can do something similar with Python, within the Spyder IDE?


回答1:


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. If that definition is in an other file, that file will be opened.

Ctrl + Leftclick

EDIT as commented by @pwagner

Rightclick -> Goto Definition

and

Ctrl + G

also work




回答2:


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.

Go to Help -> Optional Dependencies and check which of the packages are missing or not in the required version. Copy to clipboard the list and paste it into an editor and store the file as 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. It should work now!



来源:https://stackoverflow.com/questions/27439431/open-a-function-in-python-spyder-like-i-do-with-matlab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!