Why is my python extension not loading in VScode? (Microsoft) - python

I'm new to Python and programming in general, i'm learning my first steps in VScode. I was trying to create a virtual environment which I couldn't activate for some reason. I tried to solve this with a few tricks I found on stackoverflow, like disabling python.experiments.
It still didn't work so I thought I would just start without a venv, but then the python extension was not working anymore. VScode told me: "Extension activation failed, run the 'Developer: Toggle Developer Tools' command for more information'"
The errors I found where: "Activation extension 'ms-python.python' failed: e.endswith is not a function"
I uninstalled the Python and Pylance extension, accordinly I deleted all the related files before installing it again.
I was expecting VScode to be loading the Python extension succesfully again, but I still encountered the same error for which I don't know how to solve it.
Then I deleted VScode entirely before installing it again, unfortunately still the same issue..

Related

pycharm is not installing packages

So I am trying to create a chatbot in pycharm so I set up all the code and when I tried to run it, it gives me a error message saying can't find 'main' module in 'C:\Users
So I tried fixing it by setting up a new folder called virtual environment yet it gives me the same error
On the off chance it doesn't give me that error it tells me it cannot input chattterbot so I go to project interpreter to try and install it, it gives me the error message
Error occurred when installing package 'Chatterbot' I dont get why this does it while chatterbot-corpus works perfectly fine.
I tried as I said making a new virtual environment but that didnt work so after switching the new virtual environment I made and trying to put chatterbot in manually it didnt work and nothing showed. So going back to the original environment that was created when I started this project. But the same thing keeps happening it just wont install even if other programs install no problem. I looked this problem up and I found one post saying it might be setuptools fault so I down graded to the version that they said it would work but to no avail. It always comes up as Error occurred while installing package 'Chatterbot' I dont know if its something wrong with the files on my computer or the way im trying to install chatterbot. The major problem that really stumps me is that this seems to be a problem for only chatterbot and nothing else and I cannot figure out for the life of me why.

vscode python extension cant install from any source

Trying to install python extension for vscode but i always encounter an error.
by the way, python 3.10.9 is installed on my pc and works correctly
i tried installing it from the vscode editor but encounterd an error
i downloaded the vsix file using 2 different PCs but that too i always lebeled as corrupt
picture is below
any ideas pleaseenter image description here
After trying for a hours, i got the solution to my case.
for me, the internet connection was slow and caused interuptions in the installation.
I realise this when i got a stronger internet connection and the extension installed properly and without any suffering.

Extension activation failed, run the 'Developer: Toggle Developer Tools' command for more information

Unable to run/debug run in my python file. I KNOW I downloaded python on my computer. I know I downloaded the extension in VS code. Every time I try to run even a simple print("abc") line of code I get nothing in the terminal and a message that reads
"Extension activation failed, run the 'Developer: Toggle Developer Tools' command for more information."
in addition to
"Python extension loading..."
and the extension never seems to finish loading its been hours.
How do I fix this I am working out of Windows
For example I have "Extension" named Python in the image below that gets updated or installed by vsCode automatically
You have to wait for the "Extensions" to be installed.
Make sure you have an internet connection.
make sure you have a fast internet connection so that it can be installed faster.
After installation restart "vsCode"
If it doesn't work for you, try uninstalling the extension and reinstalling it
This is all I know and it happened to me
Don't know the reason, for me I installed a pervious version for python EXTENSIONS, and issue fixed screenshot
Navigate to the extensions and you'll find the extensions whose reload is required. Press reload and wait for the extension to refresh. Check the error message at the bottom to see if it still persists.
For me this problem occurred when updating VS code to version 1.75.0 and python extension version was 2022.20.2, problem fixed when updating python extension to version 2023.2.0

Environment issues with running Anaconda Python in VS Code

I am trying to learn Python and debug code for the first time in VS Code (latest edition). I have anaconda running and the code I have runs fine by itself but now I need to know how to update the code and debug it for the first time.
I keep getting the following error related to NumPy:
Exception has occurred: ImportError
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
The Python version is: Python3.7 from "C:\Miniconda2\envs\myproject_flask\python.exe"
The NumPy version is: "1.18.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: The specified module could not be found.
In the Miniconda path above the Python.exe is version 3.7.7. I tried to install NumPy like so in myproject directory:
(myproject_flask) c:\MyProject\source\MyProject.Flask>conda install numpy=1.18.5
I still get the same error when I go to F5 to debug and run to a breakpoint.
Need help with my environment.
I need to use VS Code in my Windows environment with Anaconda.
You should launch VS Code from Anaconda Navigator so that the environment is initialized.
When you have problems with importing the numpy C-extensions in Anaconda it's very likely that your virtual environment hasn't been activated. Having just Python on the path is not good enough. You also need access to the libraries. This is what the activation does.
When you are running/debugging code you should see a terminal open. You can tell from the prompt
(myproject_flask) C:\MyProject
that conda has been activated. Sometimes this just takes a bit too long for VSCode. So simply push the start button a second time.
Note that the Code Runner extension in VSCode is also known to cause this kind of problems.
However, I wonder why you are using Miniconda2 with Python3, although in general this should work.
I was getting the error even after adding all the anaconda paths, it was due to VScode running the code in the python debugger terminal which is not able to enter the conda environment.
This worked for me:
press ctrl+Shift+P > Type Terminal:Select Default profile > Select Command prompt
after this code ran in Command prompt by default, inside the environment.

Is my editor getting confused by python because I have 3.7 and 3.8?

Currently on windows 10, using VSCode to run python.
So I recently downloaded python3.8 when I was using python 3.7. Everything was working fine when I was still on python3.7. I now have multiple python directories and I think my imported libraries are throwing errors because of it.
I now have python in(these are results from searching python and right clicking -> open file location) :
C:\Python38
C:\Users\david\AppData\Roaming\Python\Python38
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 3.8
C:\Users\david\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7
As for installed programs I have :
python3.8.5(64-bit)
Python launcher
Should I add all four paths to my environment...?
Frankly I don't even know anymore how to tackle this problem. I'm not even sure what the problem is I just think its a problem. If someone could link me another stackoverflow or help that would be great.
If this isn't supposed to be a problem then I guess I have some more googling to do...
Thank you
EDIT(commented below): One specific error I keep on getting is when I install keras and tensorflow, and run a program, it keeps on asking me to install tensorflow 2.2.0 even though I've already installed it. I have C:\Python38 and C:\Users\david\AppData\Roaming\Python\Python38 in my windows path and C:\Python38 as my VSCode path –

Categories