How and why does PyCharm alter Python's import logic?

后端 未结 1 521
后悔当初
后悔当初 2021-02-19 20:49

I have a PyCharm 1.2.1 on Windows. I have to edit different branches of the same project - somewhat heavy branches, because they live in different folders on disk - say it to be

1条回答
  •  时光取名叫无心
    2021-02-19 20:51

    The correct solution is not to try to work around PyCharm's logic, but rather to use the IDE features as they're designed. That means:

    • Not use any .cmd scripts for starting up PyCharm
    • Remove all the paths specific to "alpha" and "beta" from the list of paths in Settings | Python Interpreters if any are listed there
    • Mark the "alpha/vendor" and "beta/vendor" directories as source roots in the alpha and beta projects respectively.

    Then PyCharm will resolve imports correctly and generate the correct PYTHONPATH automatically when running the application from it.

    0 讨论(0)
提交回复
热议问题