Multiple Virtual Environments

I have a monolith repo with multiple micro-services each with their own virtual environment.

How can I set it up to have Pycharm bounce between using multiple virtual environments?

I have tried setting to a folder with links to the current venv that I want to use, but pycharm seems to get confused and continues using the last one.  I have tried invalidating caches to fix this but still not luck.

If it helps, each microservice is its own python package and has the venv inside that directory structure.

Thanks,

6 comments
Comment actions Permalink

Wow, that's a bugger.  The simplest thing I can think of is to actually open one Pycharm instance per microservice subfolder, that should keep it in line with the Pycharm expectation that one project has one virtualenv.  

1
Comment actions Permalink

Any better solution?

0
Comment actions Permalink

Have you considered configuring all those virtualenvs as Project Interpreter in PyCharm and then just switch between them when needed?

0
Comment actions Permalink

Sergey Karpov It's not really a feasible solution. I constantly switch between at least two (sometimes more) microservices.

0
Comment actions Permalink

Stefanos Papanikolopoulos

There is a ticket about the correct venv activation in the terminal https://youtrack.jetbrains.com/issue/PY-25911

Unfortunately, I haven't found the ticket that would describe exactly what you are looking for, so feel free to create one.

0
Comment actions Permalink

Did a ticket get created?

 

I'm finding this would be a great feature for a use case where you have a single project with a number of AWS Lambda functions you are using for a particular project.  Since the size of the source is important, it's good to be able to have a Pipfile for each function that only has the dependencies for this function.  There's a 3 MB limit for a zipped file of code + libraries if you want to use the online lambda editor for development or troubleshooting, so I end up pulling any unnecessary libraries out of each package before uploading.

0

Please sign in to leave a comment.