Ask Your Question

How to set the root directory

asked 2020-10-21 01:59:21 -0500

justinxp's avatar

updated 2020-12-01 08:50:10 -0500

Dear all,

 File "e:\aa_work\pythonstock\jobs\", 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?

├─jobs -> *
├─libs -> *

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-10-21 06:51:21 -0500

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.

edit flag offensive delete link more


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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-10-20 20:24:29 -0500

Seen: 5,389 times

Last updated: Oct 22 '20