Debugging VS Code
DS 2023 | Communicating with Data
Windows¶
If you are installing Miniconda on Windows and are getting an error like the one in the screenshot below, read on.
That error usually isn’t a Python problem — the installer extracted the packages fine but got blocked when it tried to write them into C:\Users\█████\miniconda3. This is most likely due to an access violation of some kind.
If this happens, hit Abort rather than Ignore. An ignored link failure gives you a broken environment that fails in confusing ways later :-(
In any case, follow these steps to fix the problem:
Delete the failed install folder. d
Remove
C:\Users\█████\miniconda3entirely before retrying. A partially-linked directory from the aborted attempt will make the next install fail the same way.Also check for a stale
.condafolder in your user directory and delete that too.
Turn off real-time protection temporarily.
In Windows Security > Virus & threat protection > Manage settings, switch off Real-time protection. Conda creates thousands of hardlinks very fast, which AV heuristics frequently flag.
Also check Ransomware protection > Controlled folder access and disable it.
Turn both back on after the install finishes.
Steps 1 and 2 together resolve the large majority of these problems. If not, follow these steps:
Check whether your user folder is in OneDrive.
If the
Documentsfolder is synced to OneDrive, the sync client can lock files mid-install.Pause OneDrive syncing, or better: install somewhere outside the user profile entirely, like
C:\miniconda3.
Re-run the installer as administrator.
Right-click the
.exefile and choose Run as administrator.Pick ‘Just Me’ when asked about install scope.
Install to a short path with no spaces or non-ASCII characters to avoid a separate class of linking failures.
Re-download if it still fails. 2. Grab a fresh copy from one of the link below and verify the file size looks right before running it.
Here is the full page if you are interested repo
.anaconda .com /miniconda.
Mac¶
If you are on a Mac and VS Code can’t find conda, as in screenshot below, follow these steps:
Check if conda was installed
Open a Terminal window to see if miniconda actually installed
condaon your system. Enter the following command:ls /opt/miniconda3The output should show a list of directory and file names.
If you got this result, then Conda was installed.
If you did not get this result, try reinstalling.
Registor conda with the operating system
Next, register
condawith the operating system with this command:/opt/miniconda3/bin/conda init zshClose the Terminal window and open a new one.
Type
condaas the command prompt. You should see a lot of text explaining how to useconda.If this is true, close the Terminal window and go to VS Code.
Check if VS Code runs from the command line
In VS Code, you are going to configure it so that VS Code can run from the command ine. We need to do this because if you run VS Code from the command line, it will be able to find
conda.If VS Code is running, shut it down. Then do this from the Terminal:
code ..If VS Code runs, then you should be able to pick
condaand associated environments from the drop down list above an open notebook.The problem is fixed. Going forward, select the environment from the list at the top of the notebook.
If VS Code does not run from the command line, then open the app from its icon on do this:
In VS Code, press ⇧⌘P, type “shell command”, and pick “Shell Command: Install ‘code’ command in PATH”. It may ask for your password.
Close VS Code, open a new Terminal, and enter
code .again. It should open VS Code and you should be able to pick an environment for your notebook.If this does not work, contact the IA.