Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure custom PYTHONPATH with VM and PyCharm?

I am using IntelliJ with the Python plugin and the Remote Interpreter feature to communicate with my Vagrant VM. It sets up the remote interpreter correctly to use my VM's interpreter. But, I use a custom PYTHONPATH in my VM, and I would like IntelliJ to recognize that path and include the modules in that path when developing.

How do I configure IntelliJ/PyCharm's remote interpreter to use a custom PYTHONPATH on the VM?

like image 726
baalexander Avatar asked Jun 19 '13 18:06

baalexander


People also ask

How do I enable virtual env in PyCharm?

Press Ctrl+Alt+S to open the IDE settings and select Project <project name> | Python Interpreter. icon and select Show All. Select the target environment from the list and click OK to confirm your choice.


2 Answers

For PyCharm 5 (or 2016.1), you can:

  1. select Preferences > Project Interpreter
  2. to the right of interpreter selector there is a "..." button, click it
  3. select "more..."
  4. pop up a new "Project Interpreters" window
  5. select the rightest button (named "show paths for the selected interpreter")
  6. pop up a "Interpreter Paths" window
  7. click the "+" buttom > select your desired PYTHONPATH directory (the folder which contains python modules) and click OK
  8. Done! Enjoy it!

enter image description here

enter image description here

enter image description here enter image description here

like image 114
phil Avatar answered Sep 23 '22 02:09

phil


Instructions for editing your PYTHONPATH or fixing import resolution problems for code inspection are as follows:

  1. Open Preferences (On a Mac the keyboard short cut is ⌘,).

How to get to Settings from Menu

  1. Look for Project Structure in the sidebar on the left under Project: Your Project Name

  2. Add or remove modules on the right sidebar

Project Structure Settings in Pycharm 4.5

EDIT: I have updated this screen shot for PyCharm 4.5

like image 34
Bjorn Avatar answered Sep 26 '22 02:09

Bjorn