PyCharm include and modify External library in project

14,888

Solution 1

Well, you can add other directories as content roots:

enter image description here

Then simply mark the directory as a source root:

enter image description here

This should allow you to refactor, rename and do all the things you've wanted to do.

Solution 2

Another option would be to place libraries into separate project (or go even further and place each library in its own project) and then open this project/these projects side-by-side with the main project. This way you have clear separation between the main project and libraries used. This comes handy when you work on another project using some of the same libraries as then you only need to open already existing project containing libraries and you are done.

Share:
14,888
Bojan Jovanovic
Author by

Bojan Jovanovic

Seasoned Python/Django developer with aspirations towards devops. Founder of kortechs.io as well as PyConBalkan Avid and active member of the Python community

Updated on June 05, 2022

Comments

  • Bojan Jovanovic
    Bojan Jovanovic almost 2 years

    I have an issue where I am developing a Django project which includes other libraries we are also developing.

    My current structure is as follows:

    • Main Project
      • App1
      • App2

    • Libraries
      • Library 1
      • Library 2

    All libraries have their own setup scripts and are in separate git repositories, and we are adding them in PyCharm in the PYTHONPATH, and referencing them simply by their name. Which works good, but they are not in my current project, which means no re-factoring ( renaming, moving etc... ) and I have to use External search to find my class from the libraries.

    How do I set some libraries as project related to make them view-able and refactorable like we do on the currently set project.