How to clear Visual Studio Code cache? - python

I am in anaconda dependency hell so I keep building and then deleting different environments and the Visual Studio Code cache seems confused about what environments are available, for example looking for an environment that has been deleted.
I uninstalled and reinstalled VSC (Windows Server 2012 - waiting for upgrade) but the issue persists.
Thanks for any thoughts.

When using Python in VS Code, it recognizes the available python executable file "python.exe", which we can view in the system variables:
In VS Code, it uses the python environment used last time by default, therefore, for unused python environments, you could select other available python environments in VS Code and ignore the deleted python environments. (F1, Python: Select Interpreter)
For more information about the python environment in VS Code, please refer to this document: Using Python environments in VS Code.
Reference: How do I add Python to the Windows PATH?

Related

IDLE and PyCharm are using different versions of python, despite the python.exe PyCharm is using being installed in the same directory

I cloned a python environment and recreated it on a new machine using Anaconda Navigator with a yml file. My script runs fine in the new environment using PyCharm. The python version of this environment is 3.9.0. However the script doesn't run with IDLE because IDLE is running version 3.11.0.
IDLE is located at:
C:\ProgramData\Anaconda3\envs\CloneETL3\Lib\idlelib\idle.pat
The python interpreter which PyCharm uses is located at
C:\ProgramData\Anaconda3\envs\CloneETL3\python.exe
How can IDLE have a different version from the python interpreter when they were just installed fresh? How can I prevent multiple versions of python from running on my machine? I made sure to create a new project in PyCharm, use an existing interpreter using conda and point it to the exe I described above.
The environment was first created from a clone of my ArcGIS Pro environment.
Thanks for the help!
This is quite common in most editors. I use vscode which is similar to pycharm and the user can select the version of python (or other languages) that they wish to run.
It look like this:
The reason for this is that some users have the requirement of being compatible with previous versions. You should be able to select the latest version of each.
Alternatively you can delete all versions leaving only the one version that you desire, this would avoid confusion...
You could refer to this answer for that option: How to completely remove Python from a Windows machine?

Why Virtual Studio Code can't find my virtual environments instaled modules?

Always when I create a new Python project file, in Visual Studio Code, and I import some modules, it marks the ones VSC can't find, but they are already installed in virtual environments.
How can I fix this bug? Thanks!
Select and activate an environment
By default, the Python extension looks for and uses the first Python interpreter it finds in the system path. If it doesn't find an interpreter, it issues a warning. On macOS, the extension also issues a warning if you're using the OS-installed Python interpreter, because you typically want to use an interpreter you install directly. In either case, you can disable these warnings by setting python.disableInstallationCheck to true in your user settings.
Check this link: https://code.visualstudio.com/docs/python/environments

Django Visual Studio The environment '....' is not available

I had a virtual environment setup for Django 3 with visual studio. However at some point it seems that this previous environment has been damaged - and therefore is no longer working (nothing appears on git to have changed).
I therefore attempted to setup a new environment via the visual studio python environment options. I could setup a conda environment but it will not let me setup a python environment as "you will need to install a python interpreter...". However on the same page it states that the latest python 64 is installed.
It will not run with the conda environment that I have setup as it states "The environment '....' is not available."
I have tried creating a new solution with VS and this appears to work as intended. However it is not really an option to create a new solution as I will loose a lot of existing git commits along with this causing issues with existing servers.
Edit - Found my own answer to this question.
As new projects were allowing virtual environments to be created I figured it must be something to do with visual studio storing some reference to an old interpreter.
Therefore, Deleting the .vs folder inside my project allowed regeneration of the visual studio files and creation of a new virtual environment.

PyCharm always thows this error on creating new project and interpreter(virtual env) is missing for the project

I have got a problem with pycharm. I reinstalled everything(system python, anaconda, pycharm) since I thought it was conflicting with Anaconda. Finally, I completely got rid of Anaconda and still Pycharm throws the following error whenever I create a new project.
Unable to create process using 'C:\Users\Ritanshu Singh\AppData\Local\Programs\Python\Python37\python.exe
"C:\Program Files\JetBrains\PyCharm Community Edition
2018.3.2\helpers\packaging_tool.py" list'
Also the project(virtual env) interpreter is missing every time I create a new project(My actual system python is installed and works well, I have tried and run a raw python text file) and I can't run the python code. I googled but it shows no results.
I figured out that it has a problem to create virtual environment interpreter but I don't know why? The error code is above listed.
There is a very good documentation available for configuring the python interpreter in Pycharm: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html and
https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
Please verify that you follow these steps before starting the Pycharm.
Do not import config.
Check the user permission which starts the Pycharm(Administrative).
Add path variable for python in windows.
install and configure the pip that will help you to download the package while setting up the interpreter.
I found that from Python version 3.3+, the built-in venv module is used, instead of the third-party virtualenv utility. It is written on PyCharm Official Page on this link: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html

Eclipse opens compiled python instead of source code on breakpoint

I am having some trouble with my Eclipse debugger. Every time I set a breakpoint on Python source files, when the breakpoint is hit Eclipse opens up the associated pyc compiled file.
Below are a few things I have tried:
Creating a new Eclipse project with the code
Deleting all settings files within the code
Switch to a new workspace
Re-install eclipse and PyDev completely.
The problem persists. I don't know what could possibly be causing this. The issue only occurs when a breakpoint is set. However, that renders breakpoints useless in Eclipse.
This issue only began after I tried to set up Visual Studio for Python development. In Visual Studio this issue does not occur.
Can you check if you have pydevd installed somewhere in your system and remove it if that's the case? (i.e.: run without debugging import pydevd and if you find it remove it from your interpreter).
The PyDev debugger is used in other products (such as PyCharm and Visual Studio), so, my guess is that a non-compatible version is installed somewhere instead of using the version which is shipped along with Eclipse/PyDev.

Categories