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.

Error printing sys.path

See original GitHub issue

Environment data

VS Code version: 1.19.2 Python Extension version: 0.9.1 Python Version: 2.7.14 (Anaconda) OS and version: Windows 10 , version 1709, build 16299.192

Actual behavior

Sometimes i get a No such file or directory error pointing at the line where print sys.path is placed. This does not happen every time the code is run and does not happen outside of Visual Studio Code (command prompt, powershell, ipython and jupyter are fine).

Expected behavior

I expected the code to always print correctly with no errors.

Steps to reproduce:

Create a new file in Visual Studio Code and add the following lines

import sys
print sys.path

Right click inside window and select Run python file in Terminal.

Logs

Output from Python output panel

C:\Users\aless\Documents\code\PythonProjects\Test>python c:/Users/aless/Documents/code/PythonProjects/Test/test.py
['c:\\Users\\aless\\Documents\\code\\PythonProjects\\Test', 'C:\\Users\\aless\\Miniconda2\\python27.zip', 'C:\\Users\\aless\\Miniconda2\\DLLs', 'C:\\Users\\aless\\Miniconda2\\lib', 'C:\\Users\\aless\\Miniconda2\\lib\\plat-win', 'C:\\Users\\aless\\Miniconda2\\lib\\lib-tk', 'C:\\Users\\aless\\Miniconda2', 'C:\\Users\\aless\\Miniconda2\\lib\\site-packages', 'C:\\Users\\aless\\Miniconda2\\lib\\site-packages\\win32'Traceback (most recent call last):
  File "c:/Users/aless/Documents/code/PythonProjects/Test/test.py", line 2, in <module>
    print sys.path
IOError: [Errno 2] No such file or directory

Output from Console window (Help->Developer Tools menu)

/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:4054 [C:\Users\aless\.vscode\extensions\ms-vscode.cpptools-0.14.6]: Il comando `workbench.action.gotoSymbol` è presente più volte nella sezione `commands`.
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:4054 [C:\Users\aless\.vscode\extensions\ms-vscode.cpptools-0.14.6]: Il comando `workbench.action.showAllSymbols` è presente più volte nella sezione `commands`.
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:2571 [Extension Host] debugger listening on port 9333
/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:2569 [Extension Host] debugger inspector at %cDebugger listening on port 9333.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
    chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9333/6fc63825-c520-4878-abb9-a26e74f6b157

This is my fist time pointing out an issue so if I made some mistakes i’m sorry, i’m no expert, blame my lack of experience.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
hanssusilocommented, Mar 23, 2018

+1 Also experiencing a similar problem - it looks like print occasionally fails with an IOError. It’s very hard to reproduce consistently.

0reactions
brettcannoncommented, Mar 28, 2018

I believe this is the same as a Windows bug that has been reported upstream on VS Code and should get fixed at some point (I have no insight on Windows bugfix release schedules so I can’t give an ETA).

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - how to print contents of PYTHONPATH - Stack Overflow
I have tried defaulting to an empty string. And then did sys.path.insert(1, mypath) . But no change. I am still getting error for...
Read more >
Debugging with sys.path / ImportError issues
It looks in each directory specified in the special sys.path variable. Typically (but not always), sys.path contains some default folders, including the ...
Read more >
sys.path in Python - GeeksforGeeks
path is a built-in variable within the sys module. It contains a list of directories that the interpreter will search in for the...
Read more >
QGIS 3.14 python environment path details
Not really specific to QGIS, only Python stuff. Run the following to get what you want import sys print(sys.executable).
Read more >
How does python find packages?
import sys > print '\n'.join(sys.path) /usr/lib/python2.7 ... Assuming your PYTHONPATH environment variable is not set, sys.path will consist of 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