Ask Your Question
1

How to set the root directory

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

justinxp gravatar image

updated 2020-10-21 06:46:22 -0600

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

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

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

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 gravatar imagejustinxp ( 2020-10-22 06:27:17 -0600 )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

Stats

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

Seen: 199 times

Last updated: Oct 22