15

I want to set up PyCharm to work on a set of Python projects in a single window.

Lets say I have this projects structure.

~/src
├── py_project1
├── py_project2
├── py_project3
├── other_lang_proj1
└── other_lang_proj2

A system PYTHONPATH of /Library/Python/2.7/site-packages:/usr/local/lib/python2.7/site-packages:/opt/proprietary/packages

and some packages at

/opt/proprietary/packages
├── project1
├── project2
└── project3

How do I add the ~/src/py_project* projects to a single PyCharm window and have them see all of the packages in PYTHONPATH and /opt/proprietary/packages/project*?

Moving directories is not optional, and I don't want virtualenv. I want to configure PyCharm once for all of the open projects. For the record the PYTHONPATH works just fine for this setup everywhere but PyCharm.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
jeremyjjbrown
  • 7,772
  • 5
  • 43
  • 55
  • "Moving directories is not optional," does that mean it's compulsory? – pvg Dec 16 '15 at 18:54
  • @pvg I have other tools set up as well and I don't feel I should have to reorganize my workstation to accommodate Pycharm. Some of the paths in /opt are required. – jeremyjjbrown Dec 16 '15 at 18:55

2 Answers2

22

The accepted answer works and was probably the only way to achieve opening multiple projects when the answer was authored. However, adding a new content root simply adds the files in the underlying directory to the open project. Project settings such as the Python interpreter have to be shared between content root folders.

At the time of writing, PyCharm genuinely supports multiple projects in a single window. This allows different projects to be configured differently.

The official help document contains a step-by-step guide with screenshots on how to open multiple projects in a single PyCharm window.

Neil
  • 7,482
  • 6
  • 50
  • 56
Michael Seifert
  • 786
  • 5
  • 8
12

You can add directories to one, for example. Let's say you have ~/src/py_project1 open as a project. go to settings -> project: -> project structure then +Add Content Root, and add the directories one at a time.

Wissam Youssef
  • 800
  • 1
  • 10
  • 20
  • This seams to work well. I added the strategy of creating a pycharm folder that I open first to keep the project configs and now I can always open that project again instead of having to remember. I can back up the .idea folder for safe keeping and I don't have to add .idea to every .gitignore. It also stopped pestering me about managing my git repos, which I do by cli. – jeremyjjbrown Dec 16 '15 at 21:07
  • This way is old, as the user below mentioned, please use the new documentation :) – Wissam Youssef Sep 02 '20 at 22:09