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.

Python Interactive passes subprocess arguments to node instead of the provided executable

See original GitHub issue

Environment data

  • VS Code version: 1.29.1
  • Extension version: 2018.10.1
  • OS and version: Windows 10 64 Bit
  • Python version: Anaconda 3, Python 3.7, 64 Bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Relevant/affected Python packages and their versions: subprocess

Actual behavior

When the following code is run, which is supposed to start orca (Electron application from Plotly), the arguments are instead passed to node e.g. node --help output is printed, but only if the code is run in the Python Interactive Pane (using Run Cell). This also happens with other arguments than --help, but not with other executables, e.g. code, conda and others work as expected.

import subprocess
res = subprocess.run(
    args=[<path_to_orca_executable>, '--help'],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE)

print(res.stdout)

The problem also happens when I connect to the Jupyter Notebook instance launched by VS Code in my Browser, but it does not happen with a jupyter notebook instance launched in the Anaconda Terminal, nor does it happend in a REPL, when launched as a file, or in a qtconsole.

Expected behavior

Orca is run with the provided arguments.

Steps to reproduce:

  1. Install orca conda install -c plotly plotly-orca
  2. Execute above code inside a Python Interactive Pane in Code, using Run Cell

Logs

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

None.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

console.ts:134 [Extension Host] Python Extension: Error: ENOENT: no such file or directory, open 'C:\Users\<username>\.vscode\extensions\ms-python.python-2018.10.1\out\client\datascience\defaultTheme.json'
t.log @ console.ts:134
t._logExtensionHostMessage @ extensionHost.ts:437
(anonymous) @ extensionHost.ts:244
emitTwo @ events.js:126
emit @ events.js:214
emit @ internal/child_process.js:772
_combinedTickCallback @ internal/process/next_tick.js:141
_tickCallback @ internal/process/next_tick.js:180
console.ts:134 [Extension Host] Python Extension: [I 16:40:00.286 NotebookApp] JupyterLab extension loaded from C:\Users\<username>\Anaconda3\lib\site-packages\jupyterlab

console.ts:134 [Extension Host] Python Extension: [I 16:40:00.286 NotebookApp] JupyterLab application directory is C:\Users\<username>\Anaconda3\share\jupyter\lab

console.ts:134 [Extension Host] Python Extension: [I 16:40:00.290 NotebookApp] Serving notebooks from local directory: C:\Users\<username>\AppData\Local\Temp

console.ts:134 [Extension Host] Python Extension: [I 16:40:00.290 NotebookApp] The Jupyter Notebook is running at:
[I 16:40:00.290 NotebookApp] http://localhost:8888/?token=3d93585235d8531034b0571a9462f8dd19708771c2d1c4bd
[I 16:40:00.290 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

console.ts:134 [Extension Host] Python Extension: [C 16:40:00.299 NotebookApp] 
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=3d93585235d8531034b0571a9462f8dd19708771c2d1c4bd

console.ts:134 [Extension Host] Python Extension: [I 16:40:00.617 NotebookApp] Kernel started: 20c2be11-5288-4dce-806f-dd44b35f1ace

console.ts:134 [Extension Host] Starting WebSocket: ws://localhost:8888/api/kernels/20c2be11-5288-4dce-806f-dd44b35f1ace
console.ts:134 [Extension Host] Python Extension: [I 16:40:01.650 NotebookApp] Adapting to protocol v5.1 for kernel 20c2be11-5288-4dce-806f-dd44b35f1ace

console.ts:134 [Extension Host] Kernel: connected (20c2be11-5288-4dce-806f-dd44b35f1ace)
console.ts:134 [Extension Host] Python Extension: Execute for import pandas as pd
import numpy
%matplotlib inline
import matplotlib.pyplot as plt silently finished.
console.ts:134 [Extension Host] Python Extension: Execute for %cd "c:\Users\nille\Documents\Python Scripts\Pyplot" silently finished.
console.ts:134 [Extension Host] Python Extension: [I 16:40:53.197 NotebookApp] 302 GET /?token=3d93585235d8531034b0571a9462f8dd19708771c2d1c4bd (::1) 0.00ms

console.ts:134 [Extension Host] Python Extension: [I 16:41:10.171 NotebookApp] Creating new notebook in 

console.ts:134 [Extension Host] Python Extension: [I 16:41:11.718 NotebookApp] Kernel started: d3a5e5ef-ed29-4f99-9426-b157731b8fdd

console.ts:134 [Extension Host] Python Extension: [I 16:41:12.537 NotebookApp] Adapting to protocol v5.1 for kernel d3a5e5ef-ed29-4f99-9426-b157731b8fdd

I have also posted an issue at orca’s GitHub because I am unsure what is at fault here: https://github.com/plotly/orca/issues/149

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rchiodocommented, Dec 3, 2018

I don’t like guessing what other packages might or might not do.

0reactions
Clocktowncommented, Dec 3, 2018

I agree with @rchiodo - side effects should be kept minimal. This issue is now documented here, and a workaround does exist by clearing it yourself. Python packages that rely on launching external processes might want to handle this themselves if the application they want to launch does not work with that environment variable.
This extension is not at fault here. I assume VScode itself has a reason for setting this environment variable.
@DonJayamanne you could open an issue at VScode to discuss this further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Interactive passes subprocess arguments to node ...
When the following code is run, which is supposed to start orca (Electron application from Plotly), the arguments are instead passed to node...
Read more >
Why does passing variables to subprocess.Popen not work ...
I have a script which calls another Python script ...
Read more >
subprocess — Subprocess management — Python 3.11.1 ...
The stdout and stderr arguments may not be supplied at the same time as ... The input argument is passed to Popen.communicate() and...
Read more >
An Introduction to Subprocess in Python With Examples
Learn how to use the Python subprocess module along with examples.! ... It is possible to pass two parameters in the function call....
Read more >
The subprocess Module: Wrapping Programs With Python
In this tutorial, you'll learn how to leverage other apps and programs that aren't Python, wrapping them or launching them from your Python...
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