IntelliSense in Visual Studio Code not working with python packages - python

I am fairly new to python. So I installed python and my editor is Visual Studio Code. The Intellisense seems to work for this code (extension BeautifulSoup):
enter image description here
But it doesn't work for this:
enter image description here
I tried to restart my computer, but it didn't help.
I have also tried to use virtual enviroments and I also selected the right associated interpreter. To use python in Visual Studio Code, I installed following extensions:
MagicPython
Pylance
Python
Python Extension Pack
Visual Studio IntelliCode
Do you have any Idea why my Intellisense is not working for packages?

In VS Code, the "Intellisense" function of Python code is provided by the the Python extension, and the language service provided by "Pylance" provide us with docsing content.
Therefore, it is recommended that you "disable" other extensions to avoid interference between them and affect the use of the "Intellisense" function.
In addition, if it still doesn't work, please reinstall the Python extension and reload VS Code.

Related

Configuring Visual Studio 2022 to develop Python projects in WSL2

I installed WSL2 and use Visual Studio (VS) 2022 on the windows. I want to configure my VS 2022, so I can develop Python projects in WLS2. All tutorials I find online only talks about visual studio code. I don't want to install another IDE. Does anybody know how to do that or point me to some material?
Unfortunately not at this time, no. The VSCode integration with WSL is done through the use of an extension that creates an interop server between Windows VSCode and the Linux side of WSL. There isn't an extension like that for Visual Studio, however.
The only WSL integration that I'm aware of in Visual Studio 2022 is the inclusion of a WSL toolchain that allows you to target WSL/Linux in C++ projects. But nothing that I'm aware of for Python, no.
I believe you'll need to install an additional IDE to get Python/WSL support, sorry.
Not sure if VS is available for Linux or WSL2 yet.
If you look at https://visualstudio.microsoft.com/downloads/, only Windows & Mac seem to be supported.
So you have 2 main options:
Use VS on Windows itself. Then you just need to install the Python Tools for Visual Studio (PTVS) to be able to support Python development
Use VS Code on WSL2 - it's pretty lightweight to install anyway as a code editor, but can be endowed with comparable features to VS
EDIT: It may be that I'm misunderstanding the question as pointed out below by NotTheDr01ds, and instead you want to target WSL2 from the VS IDE, developing Python.

Compile and Run Python program in visual studio without the Python extension

I am using Visual Studio 2019 as the text editor to write python program. I want to compile and run the program in the Visual Studio without downloading the VS python extension. I have installed Python 3.8 in the default C://Users/Dell/AppData/Local/Programs/Python/Python38 location.
I do not want to download the extension because the extension installs Python 3.7 on a different location which sometimes become hard to access..
I'm going to make an assumption here that you are relatively new to the Python language. Python isn't "compiled" it's interpreted.
I'm also going to make a recommend (and I should point out that this is purely my own opinion) that you use Visual Studio Code. There is a really good guide for how to get up and running with Python. In general though:
Install Python 3.7 from the official website
Install VS Code
Open VS Code, install the Python extension
Create a new *.py file
Select your python version
Start editing/debugging

Preload custom module python vscode

Does the new python language server available in Visual Studio Code based on the Visual Studio one allows for the preload module option.
"python.autoComplete.preloadModules": []
And if it does indeed work with it, does it work with project modules or only modules installed in the virtualenv?
Doing something like "python.autoComplete.preloadModules": ["/path/to/module"] would work on the any of both implementations?
You can add them like below
"python.autoComplete.preloadModules": ["numpy", "pandas", "matplotlib"],
also, check the docs! :)
https://code.visualstudio.com/docs/python/editing#_autocomplete-and-intellisense

Exactly similar PyCharm alternative

I am currently using Pycharm. What I like about PyCharm are the following:
Simplicity of creating virtualenvs
Intellisense
GUI package installer
Console (automatically activates the venv)
However, I also lacked the following
intellisense for javascript (I believe they require a paid
license)
I recently tried visual studio but it lacked
GUI package installer
Is there an ide that can give me all the aforementioned features? I need to use this ide for full stack development in Python

Python Visual Studio extension doesn't show errors

I'm used to use VS to code C++ and Eclipse to code python but lately I have tried VS for both languages.
I found something very difficult to understand that while VS autocompletes it doesn't warn you about errors before runtime.
There is no warning regarding non existent variables or methods. I can't believe that VS does not warn about this kind of typical coding issues as it does for C++ code (as every IDE does).
What am I missing?
I tested this with VS2013 and VS2015.
I'm expecting something like:
Thanks
In order to get the python detailed IntelliSense support in VS2015 you have to install python tools for visual studio which provide the following:
CPython, PyPy, IronPython and more
Detailed IntelliSense
Interactive debugging
Integrated with Visual Studio features
Free and open-source
And the best thing, it's completely free.
Just download it from here:
https://www.visualstudio.com/en-us/features/python-vs.aspx
I hope it supports your question.
Update after comment:
You just need to refresh the Database. It works for me. Check to make sure the environment options are set (specifically path variable to PYTHONPATH) and the DB is refreshed.
Sometimes Deleting the __init__.py file in my source root directory did the trick
It seems that with a regular Python installation (2.x or 3.x in 32bit or 64bit) there are limited "warnings" (hovering over an undefined variable gives "unknown type"), but Syntax Highlighting / Intellisense doesn't seem to work.
Intellisense NOT Working:
Getting Intellisense to Work:
After some research I tried installing another Python interpreter for Visual Studio to work with. I went with Iron Python because it is "tightly integrated with the .NET Framework".
Download it from here --> http://ironpython.codeplex.com/downloads/get/970325
After installing IronPython open Visual Studio and set it as the "Default Environment for New Projects". You can set it in "Tools" --> "Python Tools" --> "Python Environments" (or by pressing Ctrl + K + `)
Make sure to refresh the database and Syntax Highlighting will start working. It doesn't seem very thorough, but it is there.
See photo below:

Categories

Resources