Pytest is not starting due to error:': [Errno 2] No such file or directory



  • OS: Ubuntu 18.04
  • Pycharm 18.3 (installed using snap software center)
  • Python Interpreter type: docker-compose
  • pytest version: pytest~=3.6

I try to run my test in my project and I get the following error message:
python: can't open file '/opt/.pycharm_helpers/pycharm/': [Errno 2] No such file or directory

I think this is a pycharm bug. Could you guys help me out?



If you install PyCharm using snap, by default it's installed in /snap directory, and helpers are installed in /snap/pycharm-professional/current/helpers/pycharm

In your case, PyCharm tries to find the package in /opt/.pycharm_helpers/pycharm


Please check if directory /opt/.pycharm_helpers exist at all, and also check if there are helpers in the /snap/pycharm-... directory according to the above example (might be different if you have community edition).

Please also provide your run configuration for the test

And finally, please check if you have any additional sources roots in File | Settings | Project: <project_name> | Project Structure


Using the “Invalidate Caches and Restart” function did the trick.


Please sign in to leave a comment.