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

 

 

8 comments
Comment actions Permalink

I tried your suggestion but it seem to have no effect at all.

C:\Users\ander>set PYCHARM_PYTHON_PATH=C:\Packages\python_venvs\pyherotools\Scripts\python.exe

C:\Users\ander>echo %PYCHARM_PYTHON_PATH%
C:\Packages\python_venvs\pyherotools\Scripts\python.exe

C:\Users\ander>"C:\Program Files\JetBrains\PyCharm Community Edition 2021.2.1\bin\pycharm64.exe"

When PyCharm start it just select some default interpreter. I also updated to the latest PyCharm with no improvements. Am I missing something?

0
Comment actions Permalink

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?

0
Comment actions Permalink

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? 

0
Comment actions Permalink

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.

0
Comment actions Permalink

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.

 

 

 

0
Comment actions Permalink

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?

0
Comment actions Permalink

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

0

Please sign in to leave a comment.