How do I solve Pycharm test running issue?

I'm trying to use PyCharm's inline test running/debugging functionality on a project. I have a 2023 MBP. I have Python 3.11 installed. I am using venv. I have set the Python Interpreter to be the 3.11 version of python in the .venv/bin directory. I am getting the following error:

ImportError while loading conftest '/Users/xxxxxxxxxxxxxx/tests/conftest.py'.
../conftest.py:4: in <module>
    from app import set_up_app
../../app.py:4: in <module>
    from aws_cdk import App, Environment, Tags
../../.venv/lib/python3.11/site-packages/aws_cdk/__init__.py:1422: in <module>
    from ._jsii import *
../../.venv/lib/python3.11/site-packages/aws_cdk/_jsii/__init__.py:13: in <module>
    import aws_cdk.asset_awscli_v1._jsii
../../.venv/lib/python3.11/site-packages/aws_cdk/asset_awscli_v1/_jsii/__init__.py:13: in <module>
    __jsii_assembly__ = jsii.JSIIAssembly.load(
../../.venv/lib/python3.11/site-packages/jsii/_runtime.py:55: in load
    _kernel.load(assembly.name, assembly.version, os.fspath(assembly_path))
../../.venv/lib/python3.11/site-packages/jsii/_kernel/__init__.py:299: in load
    self.provider.load(LoadRequest(name=name, version=version, tarball=tarball))
../../.venv/lib/python3.11/site-packages/jsii/_kernel/providers/process.py:354: in load
    return self._process.send(request, LoadResponse)
../../.venv/lib/python3.11/site-packages/jsii/_utils.py:23: in wrapped
    stored.append(fgetter(self))
../../.venv/lib/python3.11/site-packages/jsii/_kernel/providers/process.py:349: in _process
    process.start()
../../.venv/lib/python3.11/site-packages/jsii/_kernel/providers/process.py:260: in start
    self._process = subprocess.Popen(
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py:1024: in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py:1901: in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
E   FileNotFoundError: [Errno 2] No such file or directory: 'node'
Exception ignored in: <function _NodeProcess.__del__ at 0x106a2b740>
Traceback (most recent call last):
  File "/Users/xxxxxxxxxxxx/.venv/lib/python3.11/site-packages/jsii/_kernel/providers/process.py", line 228, in __del__
    self.stop()
  File "/Users/xxxxxxxxxxxx/.venv/lib/python3.11/site-packages/jsii/_kernel/providers/process.py", line 291, in stop
    assert self._process.stdin is not None
           ^^^^^^^^^^^^^
AttributeError: '_NodeProcess' object has no attribute '_process'
Process finished with exit code 4
Empty suite

We are using pytest, the issue seems to be with the assertions library from aws_cdk. It isn't able to find a dependency on node. I have compared my setup with two other devs and we can't see anything different in any of the test running config, python interpreters, project setup, anything in the .idea folder. I have recloned the repo, I have reinstalled PyCharm. I have node 20.9 installed via nvm. I can also see in the Python Interpreter packages that aws-cdk.asset-node-proxy-agent-v6 is present. I have node and homebrew in my PATH. Does anyone have any ideas what might be going on? Much thanks!

_____________________________________________

UPDATE and FIX - 8th Jan 2024

The issue has now been fixed. I had only used NVM to install node on my Mac and PyCharm was struggling to find node in the context of running tests in its test runner. I had to install Node using the default installer and remove NVM and then PyCharm was able to find node. I can now successfully run/debug tests in the PyCharm IDE.


 

0
Hello,
This seems to be related to this problem:https://youtrack.jetbrains.com/issue/PY-63755/Windows-PyCharm-cannot-run-debug-AWS-CDK-apps-with-WSL2
Please join the discussion and vote for the issue to raise its relevance and receive updates regarding the fix status.
0

请先登录再写评论。