Open a function in Python Spyder, like I do with MATLAB
Question:
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?
Answers:
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
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!
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?
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
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!