IntelliJ Python plugin & Run classpath

后端 未结 3 2106
挽巷
挽巷 2020-12-14 17:18

I have a project located at /home/myself/workspace/Project1, for which I created an SDK from a Python 2.7.3 Virtualenv I have setup.
This project uses some external code

3条回答
  •  别那么骄傲
    2020-12-14 17:31

    Make sure you have __init__.py in mymodule directory:

    The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later. ©

    UPDATE: In IntelliJ IDEA additional directories should be added as Module Dependencies or configured as Libraries (to be added to the Dependencies) instead of the Classpath tab of the Python SDK:

    Dependencies

    I've verified that this folder (D:\dev\lib) is added to the PYTHONPATH and import works.

提交回复
热议问题