Set interpreter on startup of pycharm
Answered
Hi,
I want to start PyCharm from another program and set the interpreter to a specific one on startup. But I have not found any way of doing that. Is it possible? And if so, how can I do it?
/ Anders
Please sign in to leave a comment.
Have you tried using the PYCHARM_PYTHON_PATH environment variable? See https://www.jetbrains.com/help/pycharm/configure-an-interpreter-using-command-line.html
I tried your suggestion but it seem to have no effect at all.
When PyCharm start it just select some default interpreter. I also updated to the latest PyCharm with no improvements. Am I missing something?
I tested it myself and it seems it doesn't work when creating a new project, but it works when opening an existing one that doesn't have an interpreter yet.
Do you have the same behavior?
Yes, its like that for me too. Which is a bit of a problem since I create a temporary project each time. Is there a way to create a project first from command line and then launch PyCharm?
A project in PyCharm is basically just a folder with a .idea folder inside, which contains project settings.
You can create a project folder manually in the terminal and then run "pycharm ." inside it. PyCharm will open it as a project and then the interpreter you set in PYCHARM_PYTHON_PATH should be used.
Thanks! Now I can get it to work. Took me a while to understand what was actually going on. It seemed like it was random whether or I got an interpreter or not. As it turns out, it can take PyCharm up to about 30 seconds before it searches for the interpreter. So sometimes I must have waited long enough while other times I did not.
Now PyCharm don't seem to need an .idea folder to search for the interpreter. The 30 s lag is not ideal for my planned use but it is no show stopper. But for any developer of PyCharm, it would be a nice feature if it was shorter.
An issue has emerged with this solution. If there is already a pycharm window open when opening a new one this way, then the wrong interpreter is selected. Is there any way around that?
That's a bug. I'll investigate it and file an issue, or you can do it yourself if you want, our issue tracker is public https://youtrack.jetbrains.com/issues/PY