First time here? Check out the FAQ!
1

Package import under WingIDE debugger

Hello WingIDE community,

First post, so respect to those who have gone before and thanks for the help and support.

I'm having trouble importing a package I am developing when running code in Wing's debug mode (Debug/Start/Continue).  The package is installed using pip and shows up correctly under "pip list".  I can also import the package and associated modules correctly using vanilla Python (including the Python shell in the Wing IDE) and the Jupyter notebook.

Basic details are:

  • OS Ubuntu 16.04 with Anaconda3 Python 3.6.0 distribution.
  • Wing Pro 6.0.5-1 with project properties setting the Python executable to the Anaconda installation.

Running in debug mode, the package imports OK using "import pfp" but any attempt to import modules from the package using e.g. "from pfp.scripts import pfp_compliance" results in the exception:

builtins.ModuleNotFoundError: No module named 'pfp.scripts'; 'pfp' is not a package

And yet, as outlined above, the same lines work fine in the WingIDE Python shell, vanilla Python and the Jupyter notebook.

Any help greatly appreciated.

Cheers,

Peter

Peter Isaac's avatar
11
Peter Isaac
asked 2017-10-17 02:57:00 -0600
Wingware Support's avatar
4.1k
Wingware Support
updated 2019-03-13 10:10:40 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

Using extra info in the email you sent to support@wingware.com I see that the problem is that your script is named pfp.py and the import is finding that first on the Python Path and importing that instead of the real pfp package installed by pip.

This is probably because you have '' or '.' on the Python Path inside Wing and not outside of Wing, or you have the actual path to the directory where your pfp.py is located on the Python Path in Wing.

You can alter this in the Python Path setting in Project Properties. Or, just rename your script since this is a general issue that could reoccur in other environments and cause confusion.

Wingware Support's avatar
4.1k
Wingware Support
answered 2017-10-17 09:16:00 -0600
Wingware Admin's avatar
231
Wingware Admin
updated 2019-03-07 07:48:58 -0600
edit flag offensive 0 remove flag delete link

Comments

Hi Wingware Support,

Many thanks for the quick response!  The tyranny of time zones (I'm in Melbourne, Australia) meant I didn't get to see it until just now.

I followed your suggestion to give the top level script a different name than the package name and I am now able to run the top level script (and the package code it uses) in the WingIDE debugger. As with so many problems, the solution is obvious with the benefit of hindsight and I am embarrassed that it didn't occur to me.

Once again, many thanks for the support and for WingIDE!

Cheers,

Peter

Peter Isaac's avatar Peter Isaac (2017-10-17 17:22:00 -0600) 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