简体   繁体   中英

How to fix problem with working-directory/import-root with Docker virtual environment in Pycharm

I am working on setting up a debugging environment for a Docker application in PyCharm. The application happens to be anonlink-entity-service ( https://github.com/data61/anonlink-entity-service ) and I'm using the instructions here: https://anonlink-entity-service.readthedocs.io/en/stable/debugging.html . Python version is 3.9.7, Docker version is Docker Desktop 4-0-1, PyCharm version is 2021.2.3 (Professional Edition). I'm running on Windows.

I've set up the virtual environment as shown below: 在此处输入图像描述

docker-compose.yml is here: https://github.com/data61/anonlink-entity-service/blob/develop/tools/docker-compose.yml

The code I'm trying to debug is here: 在此处输入图像描述

And is referenced in the code like this (note the import is for entityservice and not for backend.entityservice): 在此处输入图像描述

With the workspace configured as described above I get errors indicating the import should be backend.entityservice and not entityservice. I can get around this by moving the entityservice folder to a top level folder (as shown below), however, this seems to be obviously not the intent of the creators of this code.

在此处输入图像描述

Is there a way I can configure the project so that the entityservice imports work as is and does not require me to move this module out to the root of the project?

This can be fixed in PyCharm by right clicking on the folder and then selecting "Mark Directory As --> Sources Root"

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