Julia-vscode: PyCall does not seem to get resolved correctly, even though same code works in Juno

Created on 27 Jul 2020  ยท  17Comments  ยท  Source: julia-vscode/julia-vscode

I have some Julia code that runs in Juno, but when I load the same file in vscode-julia debugging gets stuck. I load a Python package as follows:

using PyCall
@pyimport machine_common_sense as mcs
MCS=mcs.MCS
MCS_Step_Output=mcs.MCS_Step_Output
MCS_Object=mcs.MCS_Object

The extension already complains about 6 problems:

Missing reference: machine_common_sense
Missing reference: as
And four times
Missing reference: mcs

When I run it nevertheless, Julia will throw me into conversions.jl, line 94:

function convert(::Type{T}, po::PyObject) where T<:AbstractString
    if pyisinstance(po, @pyglobalobj :PyUnicode_Type)

Initially, I thought this was related to having this dependency in a virtual environment, but running VS Codium from that virtual environment didn't help. I have now even installed the same dependency into my main Python 3 environment, but it still has the same problems, whereas Juno works well. Maybe it picks up the Python 2 environment, but since the config file states "python.pythonPath": "/usr/bin/python3", I don't really think so. When I open a Python Console and run the import, everything works fine as well:

Python 3.8.2 (default, Jul 16 2020, 14:00:26) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import machine_common_sense as mcs
>>> 

Could you provide any advice on how to get the Julia extension to work in my setting? [The bigger idea is that Julia should call into Python which calls into C# to start a Unity instance I can control. There are strong technical reasons the pipeline needs to be exactly like this and the setup works well from Python as well as Julia via Juno.] I would really like to VS Codium instead of Atom, so any help would be highly appreciated. Thank you very much in advance.

System: Ubuntu 20.04 LTS (64bit), 5.4.0-40-generic, Julia 1.3.1, Python 3.8.2
Extension: julia-vscode v0.16.11
VSCodium
Version: 1.47.2
Commit: 17299e413d5590b14ab0340ea477cdd86ff13daf
Date: 2020-07-17T10:49:51.211Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Linux x64 5.4.0-40-generic snap

bug needs more info

Most helpful comment

@pfitzseb You solved the issue - it works without removing the flag, the issue was using VSCodium inside Snap even with this flag set, but your suggestion directly made me see the solution, so I attributed the solution properly to you both here and in the upstream issue. Thank you so much for your help.

PS:
Should mention explicitly: Julia: Execute File now works as well.

All 17 comments

Can you confirm that Juno's debugger can handle this case? Also, does simply running the code without involving the debug functionality work in VSCodium?

are VSCodium and Juno using the same julia project?

Internally both julia-vscode extension and Juno use JuliaInterpreter as their debugger's core. And there is this upstream issue around debugging PyCall code: https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/415

Ah, yes: That was a partial oversight on my part - your intuition is absolutely correct that the Juno debugger exhibits the same or a very similar issue. That being said, the reason I missed this is that even "normal" execution via "Run -> Run Without Debugging" fails:

โ”Œ Warning: Package VSCodeDebugger does not have PyCall in its dependencies:
โ”‚ - If you have VSCodeDebugger checked out for development and have
โ”‚   added PyCall as a dependency but haven't updated your primary
โ”‚   environment's manifest file, try `Pkg.resolve()`.
โ”‚ - Otherwise you may need to report an issue with VSCodeDebugger
โ”” Loading PyCall into VSCodeDebugger from project dependency, future warnings for VSCodeDebugger are suppressed.
โ”Œ Warning: `@pyimport foo` is deprecated in favor of `foo = pyimport("foo")`.
โ”‚   caller = _pywrap_pyimport(::PyCall.PyObject) at PyCall.jl:399
โ”” @ PyCall ~/.julia/packages/PyCall/zqDXB/src/PyCall.jl:399
Found path: /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64
Mono path[0] = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Managed'
Mono config path = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/etc'
Preloaded 'ScreenSelector.so'
Display 0 'PHL 328E1 31"': 3840x2160 (primary device).
Display 1 'PHL 328E1 31"': 3840x2160 (secondary device).
Display 2 'PHL 278E1 27"': 3840x2160 (secondary device).
Loading player data from /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/data.unity3d
Logging to /home/falk/.config/unity3d/CACI with the Allen Institute for Artificial Intelligence/MCS-AI2-THOR/Player.log
Stacktrace:


Native stacktrace:

        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0x98793) [0x7f0bb9030793]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0) [0x7f0bbf7703c0]
        /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb) [0x7f0bbf5ad18b]
        /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b) [0x7f0bbf58c859]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd1e096]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0xd908d) [0x7f0bb907108d]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0x3733f) [0x7f0bb8fcf33f]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0) [0x7f0bbf7703c0]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xca30a8]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fb852]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fe713]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fed1f]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fef90]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xdfc4a9]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x1783385]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aa5cb]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aa91e]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aaa98]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aac34]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x179a908]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x178fcbe]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xe0c11f]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xe0c636]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xe0d2d7]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd6b721]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd73c5a]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd78b0c]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd78c95]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xa1123e]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xc4093b]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x44a54e]
        /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f0bbf58e0b3]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x4572a9]

Debug info from gdb:

I refuse to debug myself!
No threads.

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/falk/shapesworld_virtualenv/lib/python3.8/site-packages/ai2thor/controller.py", line 782, in _start_unity_thread
    raise Exception("command: %s exited with %s" % (command, returncode))
Exception: command: ['/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64', '-screen-fullscreen', '0', '-screen-quality', '3', '-screen-width', '600', '-screen-height', '400'] exited with -6

It gets further, launches the Unity window, but then crashes. The same VSCodium error happens when I try Ctrl+Shift+P -> Execute File. While on the surface the error looks to me like it might occur in the Unity executable I call, the weird thing is that my Juno run looks much better:

Starting Julia...
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.1 (2019-12-30)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |
โ”Œ Warning: `@pyimport foo` is deprecated in favor of `foo = pyimport("foo")`.
โ”‚   caller = _pywrap_pyimport(::PyObject) at PyCall.jl:399
โ”” @ PyCall ~/.julia/packages/PyCall/zqDXB/src/PyCall.jl:399
Found path: /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64
Mono path[0] = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Managed'
Mono config path = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/etc'
Preloaded 'ScreenSelector.so'
Display 0 'PHL 328E1 31"': 3840x2160 (primary device).
Display 1 'PHL 328E1 31"': 3840x2160 (secondary device).
Display 2 'PHL 278E1 27"': 3840x2160 (secondary device).
Loading player data from /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/data.unity3d
Logging to /home/falk/.config/unity3d/CACI with the Allen Institute for Artificial Intelligence/MCS-AI2-THOR/Player.log
beginend

julia> 

which is expected behavior. I should mention I'm not an experienced Julia developer, so maybe someone more familiar with the language would spot something obvious about my configuration which causes this.

"Normal" execution is the Julia: Execute File command. IIRC there's a bug in VSCode where the run config isn't updated properly when switching from "without debugging" to "with debugging" or vice versa.

Good point, but just to confirm: The last error I provided also occurs on a fresh VSCodium instance when the first thing I do is run Julia: Execute File.

I have built a minimal example. Unfortunately, you need to download three files:

Note that these are from a well-known DARPA-affiliated company and the details are explained here, so there should be no security concerns about running it. [It is also fully public and I have explicit clearance to post the code below.] You need to make the first file executable (Linux binary!), extract the second file right next to it and finally extract the third archive somewhere. Afterwards please just adapt scene_path below to point to the file with the same name in extracted folder from the third file as well as mcs_executable_path to point to the executable from file 1.

Optional explanation: You do not need to point to the second file, since it is right next to the executable. If the executable MCS-AI2-THOR-Unity-App-v0.0.10.x86_64 is in a folder, the folder MCS-AI2-THOR-Unity-App-v0.0.10_Data extracted from file 2 needs to be right next to it in the same folder. That's all. [Also note that the solution is built in a convoluted way since that's what I had at hand - of course, you would do this in a single vcat() command in any production code.]

using PyCall
@pyimport machine_common_sense as mcs
MCS=mcs.MCS
MCS_Step_Output=mcs.MCS_Step_Output
MCS_Object=mcs.MCS_Object

pathlib = pyimport("pathlib")

solution = push!([push!([push!([push!([push!([push!([
      "RotateLook, rotation=-40"], "MoveAhead, amount=1.0",
      "MoveAhead, amount=0.5", "RotateLook, rotation=-90");
      repeat(["MoveAhead, amount=1.0"], 3)], "MoveAhead, amount=0.5");
      repeat(["RotateLook, rotation=-40"], 9);
      repeat(["MoveAhead, amount=1.0"], 4)], "RotateLook, rotation=-45");
      repeat(["MoveAhead, amount=1.0"], 8)], "RotateLook, rotation=37");
      repeat(["MoveAhead, amount=1.0"], 2)],
      "PickupObject, objectId=96c608b1-8b50-4dea-a12e-541a3204912a",
      "RotateLook, rotation=185"); repeat(["MoveAhead, amount=1.0"], 6)],
      "RotateLook, horizon=45", "DropObject, objectId=96c608b1-8b50-4dea-a12e-541a3204912a")

scene_path="/home/falk/mitibm/AI2Thor_MCS/dataset_eval2/interaction_scenes/transferral_goal-0772.json"
mcs_executable_path="/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64"
config_data, status = MCS.load_config_json_file(scene_path)
controller = MCS.create_controller(mcs_executable_path)
output = controller.start_scene(config_data)
for next_action in solution
      output = controller.step(next_action)
end
classification = "classification"
confidence = 1.0
controller.end_scene(classification, confidence)

When run the code in Juno with Juno -> Run All this works perfectly with output:

โ”Œ Warning: `@pyimport foo` is deprecated in favor of `foo = pyimport("foo")`.
โ”‚   caller = _pywrap_pyimport(::PyObject) at PyCall.jl:399
โ”” @ PyCall ~/.julia/packages/PyCall/zqDXB/src/PyCall.jl:399
Found path: /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64
Mono path[0] = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Managed'
Mono config path = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/etc'
Preloaded 'ScreenSelector.so'
Display 0 'PHL 328E1 31"': 3840x2160 (primary device).
Display 1 'PHL 328E1 31"': 3840x2160 (secondary device).
Display 2 'PHL 278E1 27"': 3840x2160 (secondary device).
Loading player data from /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/data.unity3d
Logging to /home/falk/.config/unity3d/CACI with the Allen Institute for Artificial Intelligence/MCS-AI2-THOR/Player.log

julia>

Whereas when I run it in VSCodium via Ctrl+P -> Julia: Execute File it errors out:

โ”Œ Warning: `@pyimport foo` is deprecated in favor of `foo = pyimport("foo")`.
โ”‚   caller = _pywrap_pyimport(::PyObject) at PyCall.jl:399
โ”” @ PyCall ~/.julia/packages/PyCall/zqDXB/src/PyCall.jl:399
Found path: /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64
Mono path[0] = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Managed'
Mono config path = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/etc'
Preloaded 'ScreenSelector.so'
Display 0 'PHL 328E1 31"': 3840x2160 (primary device).
Display 1 'PHL 328E1 31"': 3840x2160 (secondary device).
Display 2 'PHL 278E1 27"': 3840x2160 (secondary device).
Loading player data from /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/data.unity3d
Logging to /home/falk/.config/unity3d/CACI with the Allen Institute for Artificial Intelligence/MCS-AI2-THOR/Player.log
Stacktrace:


Native stacktrace:

        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0x98793) [0x7f6c991d6793]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0) [0x7f6c9f9163c0]
        /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb) [0x7f6c9f75318b]
        /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b) [0x7f6c9f732859]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd1e096]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0xd908d) [0x7f6c9921708d]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0x3733f) [0x7f6c9917533f]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0) [0x7f6c9f9163c0]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xca30a8]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fb852]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fe713]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fed1f]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fef90]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xdfc4a9]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x1783385]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aa5cb]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aa91e]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aaa98]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aac34]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x179a908]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x178fcbe]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xe0c11f]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xe0c636]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xe0d2d7]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd6b721]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd73c5a]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd78b0c]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd78c95]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xa1123e]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xc4093b]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x44a54e]
        /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f6c9f7340b3]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x4572a9]

Debug info from gdb:

I refuse to debug myself!
No threads.

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/falk/shapesworld_virtualenv/lib/python3.8/site-packages/ai2thor/controller.py", line 782, in _start_unity_thread
    raise Exception("command: %s exited with %s" % (command, returncode))
Exception: command: ['/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64', '-screen-fullscreen', '0', '-screen-quality', '3', '-screen-width', '600', '-screen-height', '400'] exited with -6

It would be great if you could take a look - I would love to work with your extension, but this is blocking me. Finally, please also take into consideration that it might be something simple, since this is my first project with Julia. Thank you in advance.

Same versions as listed in first post except I'm now on extension julialang.language-julia-insider v1.0.2.

Following up on this, since this has filed a month ago. Is there anything I can do to unblock this? I'm sure fully working PyCall support is not only relevant for me, but for other developers as well. However, it is not clear how I can help beyond the minimal example I provided above which works in Juno and breaks in VSCode - trying to fix this entirely on my own seems risky, since my time and experience with Julia and VSCode extensions are quite limited. What is the best way forward? Thanks in advance.

I just tried to repro this, but can't get past the second line:

shell> ls -l
total 26796
drwxr-xr-x 2 pfitzseb pfitzseb    77824 Apr 22 15:50 interaction_scenes
-rw-r--r-- 1 pfitzseb pfitzseb     1377 Sep  1 12:29 main.jl
drwxr-xr-x 6 pfitzseb pfitzseb     4096 Sep  1 12:38 MCS-AI2-THOR-Unity-App-v0.0.10_Data
-rwxr-xr-x 1 pfitzseb pfitzseb 27348456 Sep  1 12:18 MCS-AI2-THOR-Unity-App-v0.0.10.x86_64

julia> using PyCall

julia> include("main.jl")
ERROR: LoadError: PyError (PyImport_ImportModule

The Python package machine_common_sense could not be found by pyimport. Usually this means
that you did not install machine_common_sense in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package.  To install the machine_common_sense module, you can
use `pyimport_conda("machine_common_sense", PKG)`, where PKG is the Anaconda
package the contains the module machine_common_sense, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python.   As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'machine_common_sense'")

Where can I get that python package from (or is it already included in one of the downloads and I just need to point python to it)?

@pfitzseb Apologies - should have pointed that out clearer above - the setup instructions are given on https://github.com/NextCenturyCorporation/MCS/tree/master/python_api In short: You just need to install some pip dependencies in 3 steps:

  • pip3 install -r requirements.txt with this requirements file
  • pip3 show ai2thor
  • pip3 install git+https://github.com/NextCenturyCorporation/MCS@latest

The last command (which depends on the first two) should provide the machine_common_sense package you need.

Thanks so much for looking into this - please just let me know if there is anything else I can assist with.

Alright, that works.

I can't run the code in a plain Julia 1.5 (or 1.3.0) session though and get the same error you're seeing under VSCode:

julia> include("main.jl")
Found path: /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64
no boot config - using default values

(Filename:  Line: 495)

Mono path[0] = '/home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Managed'
Mono config path = '/home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/etc'
Display 0 '0': 2560x1440 (primary device).
Loading player data from /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10_Data/data.unity3d
Logging to /home/pfitzseb/.config/unity3d/CACI with the Allen Institute for Artificial Intelligence/MCS-AI2-THOR/Player.log
Stacktrace:


Native stacktrace:

        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0x98793) [0x7fe98b380793]
        /usr/lib/libpthread.so.0(+0x140f0) [0x7fe99d7300f0]
        /usr/lib/libc.so.6(gsignal+0x145) [0x7fe99d590615]
        /usr/lib/libc.so.6(abort+0x116) [0x7fe99d579862]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd1e096]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0xd908d) [0x7fe98b3c108d]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0x3733f) [0x7fe98b31f33f]
        /usr/lib/libpthread.so.0(+0x140f0) [0x7fe99d7300f0]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x11067c0]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xc818ec]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xc7ebcd]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xc7ebf4]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x936faa]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xc2df12]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xc40883]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x44a54e]
        /usr/lib/libc.so.6(__libc_start_main+0xf2) [0x7fe99d57b152]
        /home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x4572a9]

Debug info from gdb:

I refuse to debug myself!
No threads.

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pfitzseb/.local/lib/python3.8/site-packages/ai2thor/controller.py", line 782, in _start_unity_thread
    raise Exception("command: %s exited with %s" % (command, returncode))
Exception: command: ['/home/pfitzseb/vscode-issue1524/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64', '-screen-fullscreen', '0', '-screen-quality', '3', '-screen-width', '600', '-screen-height', '400'] exited with -6
^C^C^C^C^CWARNING: Force throwing a SIGINT

I'm getting the same error in Juno as well.

Can you upload the output of the Julia Client: Debug Info command in Juno? It's possible you have some setting that makes your code run for some reason.

@pfitzseb Apologies for only seeing your response now. The Debug Info is this:

# Atom:
Version: 1.50.0
Dev Mode: false
Official Release: true
{
  "node": "12.0.0",
  "v8": "7.3.492.27-electron.0",
  "uv": "1.27.0",
  "zlib": "1.2.11",
  "brotli": "1.0.7",
  "ares": "1.15.0",
  "modules": "70",
  "nghttp2": "1.34.0",
  "napi": "4",
  "llhttp": "1.1.1",
  "http_parser": "2.8.0",
  "openssl": "1.1.0",
  "icu": "63.1",
  "unicode": "11.0",
  "electron": "5.0.13",
  "chrome": "73.0.3683.121"
}
# julia-client:
Version: 0.12.5
Config:
{
  "currentVersion": "0.12.5",
  "firstBoot": false,
  "juliaOptions": {
    "startupArguments": [
      "--startup-file=no"
    ]
  },
  "uiOptions": {
    "enableMenu": true,
    "enableToolBar": true
  }
}


# ink:
Version: 0.12.4
Config:
undefined


# uber-juno:
Version: 0.3.0
Config:
{
  "disable": true
}


# language-julia:
Version: 0.19.3
Config:
undefined


# language-weave:not installed


# indent-detective:
Version: 0.4.0
Config:
undefined


# latex-completions:
Version: 0.3.6
Config:
undefined


# versioninfo():
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_INSTALLATION_PATH = /opt/julia
  JULIA_NUM_THREADS = 6

Status `~/.julia/environments/v1.5/Project.toml`
  [c52e3926] Atom v0.12.20
  [864edb3b] DataStructures v0.17.20
  [ea4f424c] Gen v0.3.5
  [b0b986e5] GenAgent v0.1.0 `~/.julia/dev/GenAgent`
  [f2c34361] GenGridSLAM v0.1.0 `~/.julia/dev/GenGridSLAM`
  [5d8bcb5e] Julog v0.1.5
  [e5e0dc1b] Juno v0.8.3
  [5fb14364] OhMyREPL v0.5.6
  [2c8894f9] PDDL v0.1.1
  [d96e819e] Parameters v0.12.1
  [3f517155] Plinf v0.1.0 `/home/falk/.julia/dev/Plinf.jl#ai2thor-demo`
  [91a5bcdd] Plots v1.6.0
  [438e738f] PyCall v1.91.4
  [295af30f] Revise v2.7.3
  [90137ffa] StaticArrays v0.12.4

However, may I ask whether you are trying to run this in a debug session only? If I save the Julia code as minimal_example.jl and simply run it, it works for me under Julia 1.5:

$ julia minimal_example.jl 
[ Info: Importing Revise
[ Info: Importing OhMyREPL
Found path: /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64
Mono path[0] = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Managed'
Mono config path = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/etc'
Preloaded 'ScreenSelector.so'
Display 0 'PHL 328E1 31"': 3840x2160 (primary device).
Display 1 'PHL 328E1 31"': 3840x2160 (secondary device).
Display 2 'PHL 278E1 27"': 3840x2160 (secondary device).
Loading player data from /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/data.unity3d
Logging to /home/falk/.config/unity3d/CACI with the Allen Institute for Artificial Intelligence/MCS-AI2-THOR/Player.log
โ”Œ Warning: Assignment to `output` in soft scope is ambiguous because a global variable by the same name exists: `output` will be treated as a new local. Disambiguate by using `local output` to suppress this warning or `global output` to assign to the existing global variable.
โ”” @ ~/Documents/minimal_example.jl:27

$ julia -v
julia version 1.5.0

I think getting debugging for it to work is a secondary issue blocked by https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/415 (cmp. aviatesk's comment above). For the moment, I'd already be happy if I could just execute it regularly in VSCode - as far as I can tell, that is not possible, whereas if I open the file in Juno via File -> Open File and then simply hit Ctrl + Shift + Enter to run it, it works as well. But when I now switch back to the same file open in VSCode and do Ctrl + Shift + P -> Julia: Execute File I hit the error again:

Debug info from gdb:

I refuse to debug myself!
No threads.

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/falk/shapesworld_virtualenv/lib/python3.8/site-packages/ai2thor/controller.py", line 782, in _start_unity_thread
    raise Exception("command: %s exited with %s" % (command, returncode))
Exception: command: ['/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64', '-screen-fullscreen', '0', '-screen-quality', '3', '-screen-width', '600', '-screen-height', '400'] exited with -6

Even when I just start a REPL and try to run the file line-by-line via Ctrl+Enter I hit the same issue. So one thing to investigate might be whether VSCode somehow automatically runs debugging to some extent.

Update: Hm - this is interesting. So I went to the TERMINAL tab, clicked the plus sign on the right to start a new bash terminal and ran the very same command that worked in pure bash for me, but now get this:

$ julia minimal_example.jl 
[ Info: Importing Revise
[ Info: Importing OhMyREPL
Found path: /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64
Mono path[0] = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Managed'
Mono config path = '/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/etc'
Preloaded 'ScreenSelector.so'
Display 0 'PHL 328E1 31"': 3840x2160 (primary device).
Display 1 'PHL 328E1 31"': 3840x2160 (secondary device).
Display 2 'PHL 278E1 27"': 3840x2160 (secondary device).
Loading player data from /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/data.unity3d
Logging to /home/falk/.config/unity3d/CACI with the Allen Institute for Artificial Intelligence/MCS-AI2-THOR/Player.log
Stacktrace:


Native stacktrace:

        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0x98793) [0x7fa05b2fa793]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0) [0x7fa061a3a3c0]
        /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb) [0x7fa06187718b]
        /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b) [0x7fa061856859]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd1e096]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0xd908d) [0x7fa05b33b08d]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10_Data/Mono/x86_64/libmono.so(+0x3733f) [0x7fa05b29933f]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0) [0x7fa061a3a3c0]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xca30a8]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fb852]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fe713]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fed1f]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x9fef90]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xdfc4a9]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x1783385]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aa5cb]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aa91e]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aaa98]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x17aac34]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x179a908]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x178fcbe]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xe0c11f]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xe0c636]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xe0d2d7]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd6b721]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd73c5a]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd78b0c]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xd78c95]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xa1123e]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0xc4093b]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x44a54e]
        /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fa0618580b3]
        /home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64() [0x4572a9]

Debug info from gdb:

I refuse to debug myself!
No threads.

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/falk/shapesworld_virtualenv/lib/python3.8/site-packages/ai2thor/controller.py", line 782, in _start_unity_thread
    raise Exception("command: %s exited with %s" % (command, returncode))
Exception: command: ['/home/falk/mitibm/AI2Thor_MCS/MCS-AI2-THOR-Unity-App-v0.0.10.x86_64', '-screen-fullscreen', '0', '-screen-quality', '3', '-screen-width', '600', '-screen-height', '400'] exited with -6

$ julia -v
julia version 1.5.0

Something fundamental about the way VSCode runs Julia commands seems to lead to this crash. Even when I run codium --disable-extensions and do Terminal -> New Terminal and run the same command I hit this error, so maybe we should escalate this to the upstream VSCode project as well? On the one hand it seems that a command that works in pure bash should not fail in the bash integrated in VSCode, but on the other it certainly is of particular interest to this extension that vanilla Julia command line invocations work as expected :thinking: I have tried this on both VSCode and VSCodium with the same results, btw.

I was able to show that the same error happens in VSCode without the Julia extension installed and was even able to build a Python-only version of that problem, cmp. https://github.com/microsoft/vscode/issues/105894 With the new information it seems to me like the biggest underlying problem needs to be fixed by the main VSCode project. However, the PyCall debugging issue in https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/415 needs to be resolved as well. While I think both affect this Julia extension significantly, I assume the bug report here can be closed for now in favor of first sorting out things upstream. Thus, I will close this issue for now and might reopen it depending on the results from the upstream issues.

Thanks so much for your help @pfitzseb - without your investigation I would not have been able to track the issue to VSCode's terminal. Highly appreciated :+1:

Might be worth checking out the Inherit Env option:
image

Maybe also dump the content of ENV (in Julia) somewhere in both contexts and compare.

@pfitzseb You solved the issue - it works without removing the flag, the issue was using VSCodium inside Snap even with this flag set, but your suggestion directly made me see the solution, so I attributed the solution properly to you both here and in the upstream issue. Thank you so much for your help.

PS:
Should mention explicitly: Julia: Execute File now works as well.

Grerat, glad you figured it out!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlperla picture jlperla  ยท  25Comments

barche picture barche  ยท  38Comments

torkar picture torkar  ยท  36Comments

phlavenk picture phlavenk  ยท  14Comments

gdkrmr picture gdkrmr  ยท  36Comments