Home > front end >  Getting OSError when vs code tries to install any packages
Getting OSError when vs code tries to install any packages

Time:12-09

I was trying to install a formatter for python in VS code and when the editor tries to install the formatter I get the following error:

ERROR: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified: 'C:\\Python310\\Scripts\\black.exe' -> 'C:\\Python310\\Scripts\\black.exe.deleteme

The whole terminal session:

PS D:\playarea> & C:/Python310/python.exe -m pip install -U black
Collecting black
  Downloading black-21.12b0-py3-none-any.whl (156 kB)                               |████████████████████████████████| 156 kB 469 kB/s----------------------------                              Requirement already satisfied: platformdirs>=2 in c:\users\youse\appdata\roaming\python\python310\site-packages (from
 black) (2.4.0)
Collecting tomli<2.0.0,>=0.2.6
  Downloading tomli-1.2.2-py3-none-any.whl (12 kB)
Collecting pathspec<1,>=0.9.0
  Downloading pathspec-0.9.0-py2.py3-none-any.whl (31 kB)
Collecting typing-extensions>=3.10.0.0
  Downloading typing_extensions-4.0.1-py3-none-any.whl (22 kB)
  Downloading click-8.0.3-py3-none-any.whl (97 kB)
gic
ERROR: Could not install packages due to an OSError: [WinError 2] The system cannot find the file specified: 'C:\\Python310\\Scripts\\black.exe' -> 'C:\\Python310\\Scripts\\black.exe.deleteme'

Important Note: I should note that I was learning about virtual environments earlier that day and I played a lot with which python interpreter should vs code use, But, I can't understand where is the wrong?

CodePudding user response:

Add the --user parameter then try again.

C:/Python310/python.exe -m pip install -U black --user

By the way, adding python to PATH is easy for you to call python.exe that you can use python -m pip instead of using the complete path.

Here's a similar issue: Error installing package with executable, which verifies it's related to permission. Add User in C:\Python310 folder security pannel with full access permission solves this problem.

Please have a try.

  • Related