On a new install of VS Code on a new machine I have come across this error.
The send to python interactive window functionality is behaving exceptionally weirdly.
It will:
- Send a single line of code to the interactive window using either shift+enter or right-click and select, when the cursor is on that line.
It will not:
- Send any code to the interactive window when code is selected (by highlighting) either through shift+enter or right click and select.
I have ticked the box is settings marked "Python > Data Science: Send Selection To Interactive Window".
Anyone else experienced this problem or have suggestions to fix it?
VS Code version: 1.14.1
Python version: 3.7.4
Python VS code extension: 2020.1.57204
After some searching I have found that there is an issue with the Python VS Code Extension version 202.1.57204.
The solution to this is to install the previous version in VS Code (209.11.50794).
To do this go to the extensions tab on the left side, right click on the "Python" extension and select "Install another version...". Any previous version should work, but I chose the most recent before 2020.1.507204.
I am expecting Spyder's Ipython console equivalent in IntelliJ or PyCharm where i can get results of data structures used in the code. When i am doing data analysis, i run a snippet of code in console like dataframe or variable to see its contents. I am expecting a similar window of Spyder in IntelliJ
You can start an Ipython instance by selecting View -> Python Console in the menu.
It is also possible to set a breakpoint somewhere in your code and choose Debug instead of Run. In this case you usually see two tabs once the breakpoint is reached. Debugger shows the stack trace and variable viewer.
Console shows the output of your program. To make it interactive you need to click the (unlabeled) button looking like a command prompt which is selected in the following screenshot from the official documentation.
.
If stacktrace, variable explorer or console are missing, you can click the Restore layout button (above the sorting icon in the screenshot). If you want to see console and variable explorer next to one another or in seperate windows you can drag and drop them as you like.
I recently upgraded computers and I switch from using Python to Canopy Express since all the packages I use in my coding comes included in Canopy. However, when I went to run a program I wrote that uses matplotlib to create interactive plots that I could click on data points using 'pick_event' in Canopy, I'm getting a few issues with the program that I didn't have in Python. When I run the program, Canopy displays the graph and then immediately moves to the next line of code. This creates a problem for me since I want the graph to be interactive and it doesn't give me a chance to choose my data points I want. I have found ways to leave the graph up (adding in a raw input after displaying the plot or not closing the plot in the program) but Canopy crashes when I try to move or click on the plot. Is there any way I can fix this issue so I can use 'pick_event' command?
Thanks for the help
It seems likely that your code is not written to optionally run in IPython's %pylab mode (or, equivalently in this context, %matplotlib mode), which starts a GUI event loop for you and in many cases makes interactions between prompt and GUI easier. You might consider adapting your code to be able to do this, but meanwhile you can test this hypothesis by disabling pylab mode in the Canopy Preference menu (Python tab).
This article may be relevant:
Using Wx/WxPython in Canopy's IPython panel
I was wondering how to get PyCharm to display import errors?
It was previously working for me and now it stopped. PyCharm still shows other python syntax errors, and will autocomplete. However, there is no red squiggly line shown under unknown references.
You can control all of the code inspection errors in the settings.
Go to File then Settings. Search for Inspections in the left pane. In the search area on the right type "Python" to see all inspections for Python. Go down to "Unresolved references" and make sure it is checked to fix your problem.
The following is a screenshot showing how it should look:
Many python IDE's boasts of providing code-completion (code insight), PyCharm is one of those IDE's. However, it seems to me that the provided code-completion is extremely limited. Let me give you an example to make it clear:
import numpy as np
m = np.random.random((3,5))
m.
Hitting CTRL-space after 'm.' will not give me any code-completion, -no matter how hard I hit it ;).. I guess this is because the IDE would have to do type inference to know the type of the variable 'm', and that this isn't trivial in the domain of dynamic programming languages.
Now, PyCharm comes with a setting called "Collect run-time types information for code insight", which indeed sounds promising. However, it doesn't seem to fix the problem mentioned above.. I am still not able to get code-completion on the variable 'm'.
Thus far, I have only found one way to get code-completion on variables in PyCharm:
import numpy as np
m = np.random.random((3,5))
''':type : np.matrix'''
m.
In this example I am able to get code-completion when pressing CTRL-space after 'm.', and this is because I am helping the IDE by specifying the type of the variable with a docstring. I am, however, not satisfied with this way of getting code-completion, because it adds unnecessary verbosity to the code with all these docstrings (not to mention all the extra keyboard-typing)...
IPython to the rescue.. (maybe?)
Now, if we start IPython in a linux-terminal, and enter the first piece of code, we will be able to get code-completion all the way, -even for the variable 'm'. (where the code-completion in IPython is achieved by pressing TAB instead of CTRL-space)..
I don't have much experience with IPython, but I believe that I've heard something about IPython constantly executing the code in a loop or something like that...
I am thinking that it should be possible to use IPython to achieve REAL code-completion on all variables in the editor of PyCharm....
Is there a way to setup PyCharm to use IPython for code-completion?
Note that I am not satisfied with sending the code to a terminal window/console, or something like that, I want code-completion inside the editor of PyCharm...
I have looked at questions like this Adding ipython as an interpreter in Pycharm Ubuntu, but it seems to be about using IPython in the console, -not in the editor... There are also plenty of questions talking about code-completion in IDE's, but they all seem to have the same unsatisfying level of code-completion as PyCharm...
My setup
OS: Debian testing
python: Python3 and IPython3
IDE: Pycharm 3.0.2 professional edition
It cannot tell what returns are from functions(with out actually running the script, thats why ipython knows what it is (it has actually run the code and recieved back an object it can introspect)
if you want code completion without having to actually execute your script up to where you are entering text you have to do an extra step
import numpy as np
m = np.random.random((3,5))
assert isinstance(m,np.ndarray)
m. #now you get code completion (since the IDE now knows the class of m, without having to execute your script)
I had the same question, I found the answer here:
https://www.jetbrains.com/pycharm/help/using-ipython-notebook-with-pycharm.html
What you need to do is to create a ipython notebook in the project tool window. This is a file with the extension '.ipynb'. Right click on the directory where you want to put the file, select 'New-->File', enter a file name in the dialog box and give the file extension .ipynb. Open the notebook file and when you start to type something in the window, a drop down window appears with objects in the namespace plus any commands that start with the letters already typed.
To achieve iPython like functionality in pycharm, you can do it two ways:
setup a breakpoint, and debug your code. when it reaches the breakpoint, go to the console tab right below the editor, and launch a command line by clicking the button that says show command line
Launch a python command line from your console (without running debugger), by clicking on Tools, Run Python console