How to replicate Pycharm script call in Windows command line?

I ran into an issue (more details here) working with PyCharm where a script was run successfully using the IDE Run/Debug tools, but failed when running from a command line. I'm wondering if it possible to replicate the environment settings that PyCharm uses when running/debugging a script.

For example:

The Python interpreter is an Anaconda 3 environment located at "C:\Users\myuser\Anaconda3\envs\test_numpy\python.exe" and my script is located at "D:\userdata\myuser\library\dev\debug\test_numpy\". The Run/Debug configuration (looks like this) has Add content roots to PYTHONPATH ticked and the environment argument PYTHONUNBUFFERED=1. Running the script from command line starting in the test_numpy folder like this:

set PYTHONPATH=D:\userdata\myuser\library\dev\debug\test_numpy;C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\plugins\python-ce\helpers\third_party\thriftpy;C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\plugins\python-ce\helpers\pydev;C:\Users\deimos\.PyCharmCE2019.3\system\cythonExtensions;D:/userdata/myuser/library/dev/debug/test_numpy

Did not solve the problem. Is it possible to replicate the PyCharm environment through command line, and if so what variables do I have to set?

Please sign in to leave a comment.