AREPL-vscode icon indicating copy to clipboard operation
AREPL-vscode copied to clipboard

ERR_STREAM_DESTROYED when using ARPEL with pipenv

Open freyn42 opened this issue 4 years ago • 8 comments
trafficstars

Describe the bug Error ERR_STREAM_DESTROYED occurs when trying to use ARPEL with pipenv.

To Reproduce

  • Create pipenv environment
  • Point python interpreter to pipenv
  • Start typing
  • See error

Expected behavior Automatically evaluates python code in real-time

Error message When using 'afterDelay' as trigger

`internal arepl error: Error stack: Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed at doWrite (_stream_writable.js:399:19) at writeOrBuffer (_stream_writable.js:387:5) at Socket.Writable.write (_stream_writable.js:318:11) at PythonShell.send (c:\Users\anon.vscode\extensions\almenon.arepl-2.0.1\node_modules\python-shell\index.js:285:20) at PythonEvaluator.execCode (c:\Users\anon.vscode\extensions\almenon.arepl-2.0.1\node_modules\arepl-backend\index.js:71:22) at ToAREPLLogic.onUserInput (c:\Users\anon.vscode\extensions\almenon.arepl-2.0.1\out\src\toAREPLLogic.js:80:34) at PreviewManager.onAnyDocChange (c:\Users\anon.vscode\extensions\almenon.arepl-2.0.1\out\src\PreviewManager.js:278:51) at listOnTimeout (internal/timers.js:551:17) at processTimers (internal/timers.js:492:7)

Print Output: Traceback (most recent call last): File "c:\Users<username>.vscode\extensions\almenon.arepl-2.0.1\node_modules\arepl-backend\python\arepl_python_evaluator.py", line 329, in arepl_result_stream.open_result_stream() File "c:\Users<username>.vscode\extensions\almenon.arepl-2.0.1\node_modules\arepl-backend\python\arepl_result_stream.py", line 15, in open_result_stream result_stream = open(3, "w") OSError: [WinError 6] The handle is invalid Variables:`

When using 'onSave' as trigger

`internal arepl error: Error stack: Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed at doWrite (_stream_writable.js:399:19) at writeOrBuffer (_stream_writable.js:387:5) at Socket.Writable.write (_stream_writable.js:318:11) at PythonShell.send (c:\Users\anon.vscode\extensions\almenon.arepl-2.0.1\node_modules\python-shell\index.js:285:20) at PythonEvaluator.execCode (c:\Users\anon.vscode\extensions\almenon.arepl-2.0.1\node_modules\arepl-backend\index.js:71:22) at ToAREPLLogic.onUserInput (c:\Users\anon.vscode\extensions\almenon.arepl-2.0.1\out\src\toAREPLLogic.js:80:34) at PreviewManager.onAnyDocChange (c:\Users\anon.vscode\extensions\almenon.arepl-2.0.1\out\src\PreviewManager.js:278:51) at PreviewManager. (c:\Users\anon.vscode\extensions\almenon.arepl-2.0.1\out\src\PreviewManager.js:244:22) at v.fire (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:55:1856) at I.$acceptModelSaved (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:86:125912) at p._doInvokeHandler (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:89:10276) at p._invokeHandler (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:89:9968) at p._receiveRequest (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:89:8638) at p._receiveOneMessage (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:89:7440) at c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:89:5568 at v.fire (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:55:1836) at d.fire (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:63:15515) at c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:104:29104 at v.fire (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:55:1836) at d.fire (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:63:15515) at t._receiveMessage (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:63:20765) at c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:63:17659 at v.fire (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:55:1836) at u.acceptChunk (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:63:12880) at c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:63:12228 at Socket.m (c:\Users\anon\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:104:12375) at Socket.emit (events.js:315:20) at addChunk (_stream_readable.js:295:12) at readableAddChunk (_stream_readable.js:271:9) at Socket.Readable.push (_stream_readable.js:212:10) at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)

Print Output: Traceback (most recent call last): File "c:\Users<username>.vscode\extensions\almenon.arepl-2.0.1\node_modules\arepl-backend\python\arepl_python_evaluator.py", line 329, in arepl_result_stream.open_result_stream() File "c:\Users<username>.vscode\extensions\almenon.arepl-2.0.1\node_modules\arepl-backend\python\arepl_result_stream.py", line 15, in open_result_stream result_stream = open(3, "w") OSError: [WinError 6] The handle is invalid Variables:`

Other Information:

  • OS: Windows10
  • Python Version 3.7.2
  • VSCode Version 1.53.2
  • ARPEL Version v2.0.1

Additional context

  • python.pythonPath is set to "C:\Users\\.virtualenvs\Test_Project-Sy3-GYB1\Scripts\python.exe"
  • I also tried setting AREPL.pythonPath to the same path, did not change anything
  • When python for ARPEL is set to system python it works. However, modules can not be found as they are only in pipenv

freyn42 avatar Feb 12 '21 12:02 freyn42

Thanks for reporting the issue, what version of python are you using for pipenv? You can find out the version with python --version

Almenon avatar Feb 13 '21 21:02 Almenon

Ooops you specified tha already, nevermind. Python 3.7 should work...

Almenon avatar Feb 13 '21 21:02 Almenon

I wasn't able to reproduce this on windows 10 w/ python version 3.7.1, pipenv version 2020.11.15, arepl 2.0.1 (same version), and vscode 1.53.2 (same version)

Almenon avatar Feb 13 '21 21:02 Almenon

it looks like you have a extra slash in your path, maybe try removing that?

C:\Users\\.virtualenvs\Test_Project-Sy3-GYB1\Scripts\python.exe
         ^

Almenon avatar Feb 13 '21 21:02 Almenon

Thanks for your reply.

I actually have double backslashes everywhere ("C:\\Users\\<username>\\.virtualenvs\\Test_Project-Sy3-GYB1\\Scripts\\python.exe"). They are seen as escape character otherwise. They were removed when copying except for the one followed by the dot... ah no, there should have been "<username>" in between there which I forgot.

Edit: Ok. I did not forget anything... it's seen as formatting here... here we go.

freyn42 avatar Feb 14 '21 19:02 freyn42

So, I did the following:

  • Installed python 3.7.9 over the 3.7.2 one. -> python --version within the venv in vscode showd 3.7.9 without changing anything in the venv- -> error still occurred
  • Install python 3.8.7 -> had to update Pipfile to 3.8 and recreate venv for 3.8.7 -> everything worked fine
  • Changed Pipfile back to 3.7 and recreated venv for 3.7.9 -> everything worked fine
  • Removed python 3.7.9 and reinstalled 3.7.2 -> recreate venv for 3.7.2 -> same error as before

To me it seems there is an issue with python 3.7.2.

freyn42 avatar Feb 14 '21 20:02 freyn42

I tried 3.7.2 and it works for me. Can you try 3.7.2 without the venv?

Almenon avatar Feb 20 '21 04:02 Almenon

Yes. Without pipenv it works fine. I mentioned that on my first post, but did not formulate this clearly 😏 .

freyn42 avatar Feb 23 '21 10:02 freyn42