I have installed both PyCharm and Spyder (from Anaconda2).
However, when I run the exact same code (printing a very large array) from the python console, the console opened from Spyder printed out the array in less than five seconds, whereas the console opened from PyCharm took one minute to process and then printed the array.
I am wondering what is the reason for the difference in "processing time"? I like the auto-complete feature of PyCharm, but from my experience, it is slower than Spyder. Is there a solution?
(Spyder maintainer here) To avoid this problem in Spyder we only allow 500 lines to be shown in the console at a time (Note: This limit is configurable by the user)
So I'd say Pycharm's console doesn't have this functionality (although I can't tell that for sure).
Spyder has an integrated Jupyter Notebook and can show plots inline - comes with autocompletion that is just as good (if not much better) than PyCharm's terminal...
It comes with a live debugger that's much easier on the eye (side-by-side) and can execute code real damn fast!!!
Spyder gives you the option to autocomplete words in the console itself - Pycharm just uses the system command prompt/Terminal.
Related
I wanted to give VSC a try for developing some Python programs, where I only used PyCharm before. One of the most helpful features for me in Pycharm was the PyDev Console, where I can quickly try small snippets of code (think 3-10 lines), and adjust it to work the way I want it to.
I see VSC has a console, but it's much more like the regular IDLE console, where it's kind of hard to write these snippets of code (fixing something 2 lines prior for example is pretty much impossible).
I've been searching for an extension that'll give me a PyCharm-like console experience in VSC, but have been unable to find one. Is is out there? Or is there another way to get to the same result (like setting up a custom console based on the same PyDev console)?
Have you tried Jupyter Notebook and Interactive? There are provided by the Jupyter Extension which is bound with Python Extension.
Open the Command Palette (Ctrl+Shift+P), with the command of:
Jupyter: Create New Blank Notebook
Jupyter: Create Interactive Window
You can refer to the official docs for more details.
I find this mildly irritating as I am unable to see the reason.
The return statement (within a function) in VS Code (+ bash terminal) doesn't return any value, unless I explicit say print(function()), like given in the code below.
This doesn't happen in Spyder, it promptly returns the value in the console.
Why is this so? What am I missing?
The main reason is that in Spyder you use IPython console. It is an interactive shell which provides extra features. Since in your bash terminal the Python console is used instead of IPython, it does not return the value of the function when it is prompted.
In this question, the differences between IPython and Python consoles are discussed.
It is possible to use IPython in VS Code as well https://code.visualstudio.com/docs/python/jupyter-support-py
You may have to enable Python Data Science features in settings though (considered still experimental as of September 2020):
open the settings (press Ctrl+,) then search for datascience options
Personally, I find "Send Selection To Interactive Window" option very useful.
"python.dataScience.sendSelectionToInteractiveWindow": true,
Determines if selected code in a python file go to the terminal or to the Python interactive window when hitting Shift+Enter
I would like that iPython run automatically when I launch VSC instead of typing ipython and press enter in the terminal. The answer here How to set ipython/jupyter as the default python terminal for vscode? doesn't work as it is for windows but it shouldn't be really different. Also, is there something similar to the 'Execute' button in Spyder instead of typing %run filename ? Thanks !
I presume you mean you want to run the "Python Interactive Window" and not just an iPython console on startup
There is currently no way to run it on startup. At least no way without writing another extension that would run a command when opening a workspace. It would be simple for us to add one though. Probably a workspace setting. Can you log an issue here:
https://github.com/Microsoft/vscode-python/issues/new
For you second question, 'Execute' in spyder, we have 'Run Current File in Python Interactive Window'. This works on any python file. You can get to it through the context menu on a file or through the command palette.
Sadly the nice workflow of spyder is not provided by any official extension at the moment (as far as I know).
But you can implement the basics easily on your own by writing an extension. Even with no experience in TypeScript you can quickly build an extension which starts an IPython console as soon as you open a python file. I also managed to execute a startup script which implements the runfile method. VS Code also allows keybindings for your functions, so that you can almost work like you can with spyder.
Spyder modified the IPython terminal quite a bit though, so it won't feel exactly the same. But after all, everything there is open source so you could implement it yourself, which is what I'm trying to do in my free time.
I have been running into a trouble whereby Spyder IPython console is not producing Matplotlib figures as desired. I thought initially that there is something wrong in my code since jupyter notebook gives me the same wrong figures. However, when running the script in Spyder using external terminal the figures are produced as desired. Also, when I run the code in VSC the correct figures are displayed.
So the only option I am left with in Spyder is to use the external terminal to execute the code. However, it is quite a pain every time to run some codes and then manually close the terminal.
I would like to know if there is a way to permanently attach the external terminal inside Spyder? I hate the IPython console when it comes to plotting matplotlib figures!!
(Spyder maintainer here) Sorry but there's no way to dock an external Python terminal inside Spyder.
I would like to know if there is way to figure out (from the IPython console) the .py script that was used to run/execute the python commands interactively and thus got printed into the Ipython console.
For eg.
From the below screenshot, looking at the 3+3 in the Ipython console, I can see that it came in when command from untitled2.py was executed.
However when the scripts get long, and IPython output gets long and you are often shifting scripts on the left side, it can be hard to keep track.
So i was wondering if there is a way i can quickly execute some command or view some setting on Ipython console that can tell me that the above line came from untitled.py.
(Spyder maintainer here) There's no way to know from which Editor you're executing some portion of code, sorry.
However, you could use dedicated consoles (under Preferences > Run > Execute in a dedicated console) to have one console per file you execute, as long as you use F5 to run each one of them.
You could edit each .py script, so the first thing it does is to print its name and functionality.
untitled2.py:
print('untitled2.py')
...