I run vscode version 1.65.2.
Today it started citing the whole "The Zen of Python" in the terminal window every time I run a python script in the debugger.
EDIT: It turns out that it is the python interpreter that does it, not vscode. The problem apparently came after I updated ipykernel to version 6.11.0. I run python version 3.9.1 on Windows.
How can I turn it off?
I havent been able to find an answer to this anywhere.
It turned out that an import statement had found its way into my code: "import this as d", and removing it solved the problem. It is a mystery how it ended up there, I certainly haven't put it there knowingly. But problem solved!
That's really odd. I just had the exact same thing. Even the import this as d was on the first line before everything. I use vscode as well. Removing it does help. But I didn't update a kernel prior to this. It happened while I was writing code I think. Python 3.8.10 on Linux.
Related
I cannot load or run my tests, from within VS Code.
I'm a new user to Elixir, and to VS Code. I'm running Lubuntu 21.10 (Impish). I've downloaded Erlang/OTP 25 (.deb), and Elixir 1.14 (precompiled binary in /usr/share/elixir), and can get anything I need running in a Bash terminal. Again, in a standard QTerminal window,
erl, iex, mix, elixir, etc. all work fine.
In VS Code, however, I get some errors. I feel stupid, but I'm coming from Sublime Text, so please forgive me.
In the left pane of VS Code, ExUnit shows an error (red):
Clicking on this error gives me this, on the bottom right pane. The command line options, passed to mix test, seem to be the default configuration:
This result is bizarre to me, because I can open the integrated terminal, execute /bin/sh, and then run the exact mix test line that's displayed:
/usr/share/elixir/bin has been added to my PATH variable, in ~/.bashrc, ~/.profile, and /etc/environment.
However, I am further confused by all tests being excluded, and wonder if there's some connection to the core issue:
Note that I can run my tests just fine, using different command line options. I've tried adding tags, but that didn't fix the problem.
I tried Google'ing this, and played around with my settings. Here is what I have configured in the "User" settings.json, and I made sure nothing overrides this in "Workspace" settings:
Changing the useNativeTesting setting doesn't solve the problem.
On another (?) note, I get a "failed to run elixir" upon VS Code startup:
Again, I have no problem running commands from a Linux terminal, or from a terminal within VS Code.
Plot twist: If I remove the precompiled Elixir 1.14, and downgrade to an older version, via apt, the problem goes away. But Lubuntu 21.10 doesn't offer Elixir 1.14, and I'm really into using the new dbg() feature.
But for now, I cannot load or run my tests, from within VS Code, apparently because Mix cannot be found.
Thanks to Daniel Imms, from the VS Code team, for answering my question on Twitter:
"Try moving where ever you init mix and elixir (.bashrc?) into your .bash_profile and then logging out and in again or restarting. I'm guessing it's in your bashrc which doesn't run in non-interactive sessions like in tasks."
I am trying to import function query_creative inside of file query_creative.py into the notebook Notebook.ipynb. The file hierarchy is like this:
├───playground
│ Notebook.ipynb
├───src
├───queries
query_creative.py
The code I use in my notebook goes like this:
import sys
sys.path.append('..')
from src.query.query_creative import query_creative
and the thing works. However, the line with the function import is underlined by Pylance with the message: "Import could not be resolved" and when I use this function later on, it works but Pylance underlines it again. I've tried modifying the setting.json, but nothing seems to work. I thank in advance for any help!
I managed to solve it eventually by downgrading Jupyter extension to VS Code to v2022.4.1001071005. Thanks everyone for help!
Which version of vs code you have? I faced with same issue after updating to 1.70.
UPD.
Downgrading to 1.69.2 fixed that issue. However, I have another laptop with 1.70 with exact same notebook there is no such issue, so if you want to stick around 1.70 it is worth to try to completely remove vscode and install it again.
UPD2.
After a while my downgrade didn't help on another machine, so I compared Pylance output difference between them and find out, that "working" instance used legacy jupyter notebook support, while "buggy" with "LSP". After disabling option Pylance Lsp Notebooks Enabled everything worked as usual and fixed that problem
It seems that pylance is unable to determine that the code is importable. Instead of modifying your path at the beginning of the script, you could create a Python package with your code, then do:
cd your-project
pip install -e .
You can see a guide to create packages here.
With these settings, pylance and any other editor/IDE will be able to identify your project correctly.
Beware that in VSCode, you can switch the interpreter, so ensure you select one where your code is installed:
https://blog.csdn.net/qq_41019681/article/details/111193080
"python.analysis.extraPaths": [
"D:\\ProgramFiles\\Anaconda3-2021.05\\lib\\site-packages"
]
add "python.analysis.extraPaths" by
import package_name as pkg
print(pkg.__file__)
I recently got a new computer and reinstalled visual studio code but I haven't been able to run any of my files. The error has occurred with both python and C++, so I feel as though it is the IDE that is the problem. I have looked online and there are no straight answers as I have tried following some solutions which have resulted in different errors.
The error above comes up when I run (F5) a simple line of code in c++. Does anyone have a solution?
Thanks, Jacob
[EDIT]
For my python files to work I have to manually select 'Python: current file' but for c++ files they still have the same error.
First step, uninstall python from this machine.
Second, reinstall and make sure that you check the box "add to path".
It's pretty easy to miss as it's a small box, and I missed it my first time installing python earlier in the year. Here's the box you may have missed while installing.
It could be your extensions.
I had a similar error message and simply updated all of my extensions and then my SDK. I was then able to run my code within the IDE. I was using VSCode for c++ and also updated my GCC compiler along with the extensions.
Also look into your computer's environment variables, if you have changed the %PATH variables it may be affecting your ability to run/compile programs.
I am trying to use the java_kernel for jupyter (https://github.com/Bachmann1234/java9_kernel and issue 24 therein). It works fine on a Mac OSX box. But on Linux (debian), the Java shell is not starting up.
I think I tracked it down to a call like this one:
ptyprocess.PtyProcess.spawn(["/home/jupyterhub/java/jdk-9/bin/java", "-jar", "/home/jupyterhub/java/kulla/kulla.jar"])
Reading pexpect code (https://github.com/pexpect/ptyprocess/blob/master/ptyprocess/ptyprocess.py), I would expect to end up in an exec call, having the child process running python replaced by java. However, this does not happen, ps -fu shows a python child process.
I'm guessing there is some subtle difference between pty handling on linux and osx that causes the differences here?
java-9/jshell as such work from the command line.
Any help much appreciated!
Best,
Holger
There seems to be a change in the way that later versions of jdk-9 deal with terminals on Linux. I reverted to jdk-9.ea+100 and that seems to work.
I have a MSYS2 system, where I've installed python3.5 together with all of its dependencies. Furthermore, I've installed ipython using pip3.5 along with pyreadline 2.1. When I start ipython I get this prompt:
It is broken (as you can see on space between the brackets, and it does not complete any commmands - instead it inserts tabs. Anyone that have a clue what's wrong?
Yes, pyreadline is broken on windows, IPython will move away from readline on the next version (5.0). This should fix things.