Package import under WingIDE debugger


80
views
1
4 weeks ago by
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:
  1. OS Ubuntu 16.04 with Anaconda3 Python 3.6.0 distribution.
  2. 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
Community: Wing Python IDE

1 Answer


2
4 weeks ago by
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.
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
written 4 weeks ago by Peter Isaac  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »