First time here? Check out the FAQ!
1

How to set the root directory

Dear all,

Error:
 File "e:\aa_work\pythonstock\jobs\18h_daily_job.py", line 5, in <module>
  import libs.common as common

builtins.ModuleNotFoundError: No module named 'libs.common'

Below is the working directory of my project, I have some mainly .py in the sub directory called jobs. These job need to import the module of "libs", how to set the root directory?

E:.
├─docker
├─jobs -> *
├─libs -> *
├─old_jobs
├─supervisor
└─web

These are some settings I try in wing, but it does not work. Edit -> Preferences -> Files -> Default Directory Policy: Use Project's Home Directory Project-> Project Properties -> Debug/Execute -> Initial Directory -> custom: e:\aa_work\pythonstock Project-> Project Properties -> Options -> Project Home Directory -> Specified Directory: e:\aa_work\pythonstock

By the ways, if it's convenient, please tell me why none of this works.

I have checked the manual, but do not figure out yet.

justinxp's avatar
11
justinxp
asked 2020-10-21 01:59:21 -0500
Wingware Support's avatar
4.1k
Wingware Support
updated 2020-12-01 08:50:10 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

I think you want to add the parent directory of 'libs' to the Python Path in Wing's Project Properties.

Of the settings you mentioned, only Initial Directory can affect module loading in Python, if '.' or '' (representing current directory) is on the Python Path, which it may not be in your case. You can see the Python Path with 'import sys; print(sys.path)' in Python.

Default Directory Policy controls how Wing selects the starting directory for file/directory browsing dialogs and has no effect on how Python is run.

Project Home Directory controls how Wing shows files in the Project tool, since paths are shown relative either to the location of the project file or the selected directory. This also has no effect on how Python is actually run.

Wingware Support's avatar
4.1k
Wingware Support
answered 2020-10-21 06:51:21 -0500
edit flag offensive 0 remove flag delete link

Comments

Thanks, I see.

BTW, adding the parent directory of 'libs' to the Python Path: Project-> Project Properties -> Environment -> Python Path: e:\aa_work\pythonstock

justinxp's avatar justinxp (2020-10-22 06:27:17 -0500) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer