Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm External tools relative to Virtual Environment

Using the PyCharm IDE, when setting up an external tool, how can you set up the external tools with a path relative to use the current virtual env defaults.?

An example being pylint - where I'd want the virtual env version and not the system one to run.

like image 467
Danny Staple Avatar asked Jan 11 '13 12:01

Danny Staple


People also ask

How do I add an external tool in PyCharm?

Press Ctrl+Alt+S to open the IDE settings and select Tools | External Tools. button to add a new external tool.

What is the best environment for PyCharm?

So back to your question, when you create an env in Pycharm, it will ask you which env do you want to create: Virtualenv Environment , Conda Environment , or Pipenv Environment . As for me, I usually choose Pipenv Environment as this env will be bound to the current project and can generate a lock file.


2 Answers

Not sure about older versions, but in PyCharm 5 one can use $PyInterpreterDirectory$ macro. It's exactly that we want

like image 141
El Ruso Avatar answered Sep 21 '22 07:09

El Ruso


There's JDKPath macro you can use which points to the executable of the interpreter set for a project. You can combine this with the fact that many tools can be run by directly running their module(s) using the -m option of interpreter. Also there's issue PY-2734 New useful macros in external tools everyone can vote on.

like image 25
Piotr Dobrogost Avatar answered Sep 19 '22 07:09

Piotr Dobrogost