vscode python jedi client: couldn't create connection to server - python

I keep getting this message when I run Jupyter Notebook.
comment :
output:

Pylance is now the default language server (see here). As such, I resolved the issue by changing my settings.json to:
"python.languageServer": "Pylance"
You may need to install the Pylance extension, if you don't already have it.

I met this issue on Ubuntu 18.04 LTS with python interpreter python3.6.9 + VS code python extension 2022.14
If I downgrade the VS code python extension to 2022.06, it works.
If I install a new version python (e.g. python3.9), it works.
So the reason should be:
The new version python extension is not compatible with old python version 3.6.9.
Solution:
either downgrade the python extension to 2022.06(can be even earlier, not fully tested); or upgrade the python interpreter version.

Check whether the following code is specified correctly in your setting.json:
"python.languageServer":"Jedi"

Related

VSCode Python Extension: Extension host terminated unexpectedly

Running the latest version of VSCode: 1.61.2 in Windows 10. Everything was working fine until Yesterday when my Python extension gave me this error "Extension host terminated unexpectedly" and I'm unable to run or debug Python files in VSCode.
I did a complete removal of VSCode (including the App, the code folder in AppData, and the .vscode folder). But when I reboot, reinstall and run VSCode and install the Python extension by Microsoft v2021.10.1365161279, I get the exact same error.
It seems like this should just work like it has for me for many years. Is there any way to find out what is breaking it?
I can successfully open and run Python files in remote WSL instances using VSCode, just not in Windows.
[Edit: The problem turns out to be Mozilla VPN. If I exclude VSCode from it, then the Python extension works.]
Lots of people reporting issues with the Python extension on Windows right now. There's an alleged fix for the fatal performance issues here, for example, but this hasn't made it into the regular update cycle yet afaik.
I'd suggest using VS Code Insiders or disable the Python extension for the time being or find a way to revert to an earlier Python extension version.
[Update] It looks like the changelog for 2021.10.2 (20 October 2021), to version v2021.10.1365161279, includes the following fixes:
Ensure we filter out unsupported features in web scenario using
shellExecutionSupported context key. (#17811)
Fix unresponsive
extension issues caused by discovery component. (#11924)
Update debugpy to 1.5.1 to ensure user-unhandled exception setting is false by default. (#17789)
So, I'd test uninstalling and reinstalling the Microsoft Python extension. It works for me with this new update.
It turns out the problem is my Mozilla VPN. If I turn it off, then my Python extension works, and it also works if I exclude VSCode from the VPN.

VSCode issue with Python versions and environments from Jupyter Notebooks

Issue: I am having issues with the environment and version of Python not matching the settings in VSCode, and causing issues with the packages I am trying to use in Jupyter notebooks. I am using a Windows 10 machine with Python 3.9.1 installed (including older versions), with Visual Studio Code 1.52.1 . Short summary - I install a package using pip. My guess is that it associates with the latest version of Python. I set up an interpreter in VS Code for that version of python, and try to import the package. The package is not found. If I call sys.version from the Jupyter notebook, I see that a default version of Python is running (3.8.5). The simple notebook throws an error because it cannot find that package that I installed with pip.
Screenshot that shows the associations:
This error is reproducible with only the
import pygmt
command in the notebook, i.e. it does not depend on the other packages imported.
Question: How can I control the version that Jupyter notebooks will run in VSCode if changing the interpreter doesn't work? Every other issue like this that I have found was due to not choosing the correct interpreter. In this case, I have. Why is it not running that version of the interpreter?
Thank you.
Edit
This edit is in response to #Jill Cheng's answer (see my comment below for tl;dr). I can change the interpreter (lower left corner of VSCode) to match the default that VSCode wants to run. No problem.
But there still are problems.
I cannot install pygmt, the targeted package, into this version of Python (see the command in in the terminal).
I cannot make VSCode operate in the opposite direction - i.e. I can never get it to run Python 3.9.1 even when that is the interpreter I chose.
I have reinstalled VSCode now several times, and Python 3.8.5 seems to always be the default. To me, the easiest solution seems to be changing the default Python version of VSCode - in fact, isn't that the point of selecting an interpreter? It is more nebulous to me why I cannot install pygmt into Python 3.8.5, and I don't know if it is beneficial to have multiple different versions of Python all with different packages (or is this just what Python users deal with daily?).
In VS Code, the Python kernel (Python environment) used by Jupyter notebook can be independent of the Python environment we selected in VS Code (shown in the lower left corner of VS Code).
As the output in the screenshot shows, the Python kernel of Jupyter you are using is "Python3.8.5", but the module "pygmt" is not installed in this environment. (Jupyter uses the last selected Python environment by default.)
Solution: Click the Python kernel on the upper right in the Jupyter notebook, and select the python environment where the module "pygmt" has been installed. In addition, it is recommended that you reopen the jupyter file after switching Jupyter's Python kernel so that it can reload the new python kernel.
Reference: Jupyter notebooks in VS Code.

Visual Studio Code syntax highlighting not working

I am using Visual Studio Code (VSC) as my IDE. My computer just updated to Catalina 10.15.2 (19C57) and since the update, now VSC is not highlighting syntax errors. The extensions I have seem to be working and it recognizes my miniconda python environment.
Is there a solution for this yet? I was avoiding Catalina as I know it has caused lots of errors, but now that I was forced to install it I need a solution as I love VSC.
I also had the same problem for typescript react files. Tried many things and nothing worked. Finally I checked the extensions I've installed for typescript react. Disabling JavaScript and TypeScript Nightly extension worked for me
In my case, the Catalina installation didn't remove my Python installation.
After checking as suggested by #Brett Cannon in his comment, the update to Catalina uninstalled some extensions from VS Code. These are not available in the VS Code extension Marketplace anymore, so there must be an issue regarding compatibility. I fixed it after I opened my command palette (Command + Shift + p) and typed python: select linter. Then selected pylint, selected the install with conda option, Close/Open VS Code and now it's working(though it's still not shown in my extensions section in VS Code). It's necessary to point out that you will have to install pylint in every Python environment you are using. In my case I have multiple Conda environments.
It's very specific but for me it was a missing semicolon in my css (styled-component). I use styled-components in react and it didn't throw an error for missing semicolon but highlighting was suddenly gone.
I had given up and left it that way until I came up with the solution quite by accident.
If you were using the global install of Python then that was removed in Catalina which would break your virtual environment. A new install of Python and recreating the virtual environment should fix things.
Had similar issue on new vscode setup - my problem was rather that eslint warnings are not being highlighted, only errors.
After opening my eslint setup for the project - .eslintrc.js file, saw message saying that eslint needed permission accessing some files, which I did by clicking the lightbulb next to module.exports and hitting accept button.

I have two python 3 versions on my Mac. How do I use the new version and/remove the old one?

I have Python 3.6.5 and Python 3.7.4 installed.
python --version
gives me 3.6, while
python3 --version
gives me 3.7. Running code in PyCharm indicates that it is still using 3.6. How do I update it to start using 3.7, and/or remove 3.6?
I've looked around SO and other forums, but so far nothing seemed to be relevant to this specific issue.
If you want to keep your other python versions and want PyCharm to run your code in the 3.7 version you can simply go into your PyCharm preference and set the project interpreter to 3.7.
Here is a stack overflow question showing you how
If you don't see the python interpreter there you can add it manually before setting it in the preferences. Here is a doc page that might help

Python GDal installation

Having some problems with Gdal installation with python 2.7 on Windows 7 32bit. I am running MSVC 2010. I have followed the instruction from the blog website
http://cartometric.com/blog/2011/10/17/install-gdal-on-windows/
The installation is fine. At the end of it, I am able to run ogr2ogr in the MS-DOS and have gotten the similar screen as listed in the blog.
However, when I am trying to use the command "import osgeo" on the Python IDLE GUI shell. A series of error message is released, reading like the following
"DLL error:.........."
I believe that this might mean that the python binding is of wrong version. I have cleared up my installation by removing the following: Python-Gdal binding, Gdal, Python 2.7
After removing them, I have retried my installation with Python 3.2.3 instead and loaded the Gdal package and python binding accordingly. However, the same error returns.
Is there any intermediate steps that I could take to verify the installation. Any other advice I could have to have the bindings installed? Or is my reinstallation method correct?
I have tried to install FWTools too. It doesnt seem to work either. I have run the Python shell from EV-shell and type in "import osgeo". Have gotten the message "no module exist...."
Thanks
Get the precompiled gdal from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
I have some other notes on setting up postgres and postgis 2.0 here if you need it:
http://monkut.webfactional.com/blog/archive/2012/5/2/using-django-14-with-gdal-19-and-postgis-20/

Categories

Resources