question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pop-up `The argument 'file' cannot be empty. Received ''` appears when no Python is installed or when default python is selected

See original GitHub issue

Environment data

Version: 1.59.1
Commit: 3866c3553be8b268c8a7f8c0482c0c0177aa8bfa
Date: 2021-08-19T11:53:52.479Z
Electron: 13.1.7
Chrome: 91.0.4472.124
Node.js: 14.16.0
V8: 9.1.269.36-electron.0
OS: Darwin x64 20.6.0
  • VS Code version: 1.59.1
  • Extension version (available under the Extensions sidebar): v2021.8.1159798656
  • OS and version: macOS 11.15.2
  • Python version (& distribution if applicable, e.g. Anaconda): Available through nix-shell environment, Python 3.9.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): nix-shell
  • Relevant/affected Python packages and their versions: n/a
  • Relevant/affected Python-related VS Code extensions and their versions: n/a
  • Value of the python.languageServer setting: “Default”

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

Saving python files to operate without error.

Actual behaviour

Every time I save a python file. An error dialog is displayed: Screen Shot 2021-08-23 at 10 34 40 PM

“The argument ‘file’ cannot be empty. Received ‘’”

Steps to reproduce:

  1. Run VSCode from macOS.
  2. Remote SSH into a NixOS machine.
  3. Install the Python extension on the remote machine.
  4. Attempt to save a Python file. (I suspect this is triggering a format-on-save. Many other extension commands trigger the same error however.)

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

User belongs to experiment group 'pythonaa'
User belongs to experiment group 'pythonJediLSP'
User belongs to experiment group 'pythonDiscoveryModuleWithoutWatcher'
User belongs to experiment group 'pythonTensorboardExperiment'
User belongs to experiment group 'PythonPyTorchProfiler'
User belongs to experiment group 'pythonDeprecatePythonPath'
User belongs to experiment group 'pythonSortEnvs'
Starting Pylance language server.
Error 2021-08-24 04:57:04: Failed to check if file needs to be fixed EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://ssh-remote+doodoo/home/skainswo/.config/Code/User/settings.json' (Error: Unable to resolve non-existing file 'vscode-remote://ssh-remote+doodoo/home/skainswo/.config/Code/User/settings.json')
    at _handleError (/home/skainswo/.vscode-server/bin/3866c3553be8b268c8a7f8c0482c0c0177aa8bfa/out/vs/server/remoteExtensionHostProcess.js:85:158459)
    at y.readText (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:320331)
    at p.doesFileNeedToBeFixed (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:586718)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:585845
    at async Promise.all (index 0)
    at p.getFilesToBeFixed (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:585791)
    at p.updateTestSettings (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:585418) {
  code: 'FileNotFound'
}
Error 2021-08-24 04:57:04: Diagnostic Code: NoPythonInterpretersDiagnostic, Message: Python is not installed. Please download and install Python before using the extension.
Diagnostic Code: NoPythonInterpretersDiagnostic, Message: Python is not installed. Please download and install Python before using the extension.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
Error 2021-08-24 05:03:50: Failed to format imports for '/home/skainswo/dev/research/research/bayesian_optimization/vanilla_bo_quadratic.py'. TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:414:11)
    at Object.spawn (child_process.js:551:13)
    at Object.t.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:403189)
    at o.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:29:13614)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:98259)
    at s.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:97403)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:92888)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:499849
    at _provideDocumentSortImportsEdits (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:497735) {
  code: 'ERR_INVALID_ARG_VALUE'
}
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
Error 2021-08-24 05:03:58: Failed to format imports for '/home/skainswo/dev/research/research/bayesian_optimization/vanilla_bo_quadratic.py'. TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:414:11)
    at Object.spawn (child_process.js:551:13)
    at Object.t.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:403189)
    at o.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:29:13614)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:98259)
    at s.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:97403)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:92888)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:499849
    at _provideDocumentSortImportsEdits (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:497735) {
  code: 'ERR_INVALID_ARG_VALUE'
}
> conda --version
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
Error 2021-08-24 05:04:21: Failed to format imports for '/home/skainswo/dev/research/research/bayesian_optimization/vanilla_bo_quadratic.py'. TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:414:11)
    at Object.spawn (child_process.js:551:13)
    at Object.t.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:403189)
    at o.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:29:13614)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:98259)
    at s.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:97403)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:92888)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:499849
    at _provideDocumentSortImportsEdits (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:497735) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Formatting with yapf failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
Error 2021-08-24 05:04:24: Failed to format imports for '/home/skainswo/dev/research/research/bayesian_optimization/vanilla_bo_quadratic.py'. TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:414:11)
    at Object.spawn (child_process.js:551:13)
    at Object.t.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:403189)
    at o.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:29:13614)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:98259)
    at s.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:97403)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:92888)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:499849
    at _provideDocumentSortImportsEdits (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:497735) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Formatting with yapf failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
Error 2021-08-24 05:27:42: Failed to format imports for '/home/skainswo/dev/research/research/bayesian_optimization/bo_gradients_quadratic.py'. TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:414:11)
    at Object.spawn (child_process.js:551:13)
    at Object.t.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:403189)
    at o.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:29:13614)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:98259)
    at s.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:97403)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:92888)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:499849
    at _provideDocumentSortImportsEdits (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:497735) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Formatting with yapf failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
Error 2021-08-24 05:28:21: Failed to format imports for '/home/skainswo/dev/research/research/bayesian_optimization/bo_gradients_quadratic.py'. TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:414:11)
    at Object.spawn (child_process.js:551:13)
    at Object.t.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:403189)
    at o.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:29:13614)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:98259)
    at s.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:97403)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:92888)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:499849
    at _provideDocumentSortImportsEdits (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:497735) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Formatting with yapf failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''

Formatting with yapf failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
Error 2021-08-24 05:33:27: Failed to format imports for '/home/skainswo/dev/research/research/bayesian_optimization/bo_gradients_quadratic.py'. TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:414:11)
    at Object.spawn (child_process.js:551:13)
    at Object.t.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:403189)
    at o.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:29:13614)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:98259)
    at s.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:97403)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:92888)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:499849
    at _provideDocumentSortImportsEdits (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:497735) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Formatting with yapf failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''

Formatting with yapf failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
Error 2021-08-24 05:33:52: Failed to format imports for '/home/skainswo/dev/research/research/bayesian_optimization/bo_gradients_quadratic.py'. TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:414:11)
    at Object.spawn (child_process.js:551:13)
    at Object.t.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:403189)
    at o.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:29:13614)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:98259)
    at s.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:97403)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:92888)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:499849
    at _provideDocumentSortImportsEdits (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:497735) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Formatting with yapf failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
Error 2021-08-24 05:34:32: Failed to format imports for '/home/skainswo/dev/research/research/bayesian_optimization/bo_gradients_quadratic.py'. TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''
    at normalizeSpawnArguments (child_process.js:414:11)
    at Object.spawn (child_process.js:551:13)
    at Object.t.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:9:403189)
    at o.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:29:13614)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:98259)
    at s.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:97403)
    at Object.execObservable (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:78:92888)
    at /home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:499849
    at _provideDocumentSortImportsEdits (/home/skainswo/.vscode-server/extensions/ms-python.python-2021.8.1159798656/out/client/extension.js:59:497735) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Formatting with yapf failed.
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received ''

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
karrtikrcommented, Aug 27, 2021

@samuela You’re correct, we should ideally show the prompt once in case you do not have python installed, you may have missed it. You can see we also log this error:

Error 2021-08-24 04:57:04: Diagnostic Code: NoPythonInterpretersDiagnostic, Message: Python is not installed. Please download and install Python before using the extension.
Diagnostic Code: NoPythonInterpretersDiagnostic, Message: Python is not installed. Please download and install Python before using the extension.

It seems we set pythonPath as an empty string in a few places which eventually results in this error:

0reactions
karrtikrcommented, Aug 30, 2021

I have created a VSIX including the fix: https://github.com/karrtikr/vscode-python/suites/3634815359/artifacts/88030738, please try it out. You can follow the prompts from "Extensions: Install from VSIX..." in the command palette.

image
Read more comments on GitHub >

github_iconTop Results From Across the Web

Formatter black is not working on my VSCode...but why?
Once installed in Visual Studio Code, "Black Formatter" will be available as a formatter for python files. Please select "Black Formatter" ...
Read more >
Typing “python” on Windows 10 (version 1903) command ...
I installed Active Python 2.7 on Windows 10 (version 1903). On typing “python” from search, opens the Python 2.7 prompt but when I...
Read more >
IDLE — Python 3.11.1 documentation
If the module has not been saved IDLE will either prompt the user to save or autosave, as selected in the General tab...
Read more >
Visual Studio Code (Windows) - Setting up a ... - YouTube
In this Python Programming Tutorial, we will be learning how to set up a Python development environment in VSCode on Windows.
Read more >
Editing Python in Visual Studio Code
Make sure you selected a valid interpreter path by running the Python: Select Interpreter command. The formatter is not installed in the current...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found