简体   繁体   中英

Adding Project Path to Python PATH in Sublime Text

I'm collaborating on a Python project using Sublime Text with another person who uses PyCharms. PyCharms automatically adds the project path to allow easy import of modules using relative path (relative to the root of the project).

Question: In Sublime Text using the Anaconda IDE (a Sublime Text package), is there a setting we can set (ie. in a . sublime-project file) so that the project path is added to the Python PATH?

From the Anaconda configuration docs ,

your Anaconda plugin will be able to lint, complete and analyze any package and module that your configured python interpreter is able to see.

So, if you're importing local files like so:

from ..lib import module

for example, you don't need to add anything special to the configuration, because as soon as you import the package Anaconda will analyze it (within several seconds, depending on size) and be ready to offer autocomplete. However, if you have a path like /opt/company/modules/python that is not already in Python's PYTHONPATH , you can add it to Anaconda using the "extra_paths" list:

"extra_paths":
[
    "/opt/company/modules/python"
]

and any modules contained therein will be seen and processed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM