Error in file _dwt.py

302 views
Skip to first unread message

felixt...@gmail.com

unread,
May 30, 2018, 1:32:13 AM5/30/18
to PyWavelets
ModuleNotFoundError: No module named '__main__._extensions'; '__main__' is not a package

how about this solution ? 
I already install module scipy, numpy, matplotlib and pywt but it still error in this module ?

NB : I am still newby in python, thanks :)

Parikshit Bangde

unread,
May 30, 2018, 1:43:01 AM5/30/18
to PyWavelets
Try to check the version of your python . . It might be possible that you have installed scipy and pywaveletes in another version . . For example if you are working on python3.5 and u also have python 2.7 then all the lib u install are gone in 2.7 python . . While installing you need to specify the python version by using and upgrading pip3
Try pip3 install pywaveletes
But before that u need to upgrade and install pip3
Hope this might work for you
Thanks you

Gregory Lee

unread,
May 30, 2018, 1:59:20 PM5/30/18
to pywav...@googlegroups.com
On Wed, May 30, 2018 at 1:32 AM, <felixt...@gmail.com> wrote:
ModuleNotFoundError: No module named '__main__._extensions'; '__main__' is not a package

how about this solution ? 
I already install module scipy, numpy, matplotlib and pywt but it still error in this module ?


You will probably get better feedback on your problem if you can provide more info:

1.) How did you install PyWavelets?
2.) What is the exact command that leads to this error message?
3.) What is your operating system?
4.) which python version are you using?
 

Message has been deleted

Parikshit Bangde

unread,
May 31, 2018, 2:25:47 AM5/31/18
to pywav...@googlegroups.com
So have you working on same python version pls check that too
And try to install numpy lib
It's will definitely work 

On May 31, 2018 11:52 AM, <felixt...@gmail.com> wrote:
oh exactly i use python 36-32 version

i already install pip 3 in that command, so i trying like this "pip3 install scipy / pywavelets"

and that in the command prompt send me like this "Requirement already satisfied : scipy in c:\user.......\python 36-32\lib\site-packages <1.1.0> and so that numpy to"

But, it still error

"from ._extensions._pywt import Wavelet, Modes, _check_dtype
ModuleNotFoundError: No module named '__main__._extensions'; '__main__' is not a package"

Help me to solve this problem, thank you sir

--
You received this message because you are subscribed to a topic in the Google Groups "PyWavelets" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pywavelets/FW6HkIVtjG0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pywavelets+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

felixt...@gmail.com

unread,
May 31, 2018, 2:27:14 AM5/31/18
to PyWavelets
1. I use command prompt in file Python 36-32 script than i create code in cmd "pip3 install pywavelets or pywt"

2. In that error it shows this message for me: 
from ._extensions._pywt import Wavelet, Modes, _check_dtype
ModuleNotFoundError: No module named '__main__._extensions'; '__main__' is not a package

3. Oh i use windows 8.1 and install Python 3.6 and use that IDLE python to input the code

4. Python 3.6-32 version

Thank you sir, please help me to solve this problem 

felixt...@gmail.com

unread,
May 31, 2018, 2:27:43 AM5/31/18
to PyWavelets
oh exactly i use python 36-32 version

i already install pip 3 in that command, so i trying like this "pip3 install scipy / pywavelets"

and that in the command prompt send me like this "Requirement already satisfied : scipy in c:\user.......\python 36-32\lib\site-packages <1.1.0> and so that numpy to"

But, it still error

"from ._extensions._pywt import Wavelet, Modes, _check_dtype
ModuleNotFoundError: No module named '__main__._extensions'; '__main__' is not a package"
Help me to solve this problem, thank you sir

Parikshit Bangde

unread,
May 31, 2018, 2:28:29 AM5/31/18
to pywav...@googlegroups.com
Then surly u don't have numpy lib 

--

felixt...@gmail.com

unread,
May 31, 2018, 2:35:00 AM5/31/18
to PyWavelets
Yes, I already install in command prompt "pip3 install numpy lib" and success to install numpy lib but is still error and send me messages like this :

"Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\Scripts\_dwt.py", line 4, in <module>
    from ._extensions._pywt import Wavelet, Modes, _check_dtype
ModuleNotFoundError: No module named '__main__._extensions'; '__main__' is not a package"

In IDLE Python i use code like this line 1 - 10 

import numpy as np
import pywt

from ._extensions._pywt import Wavelet, Modes, _check_dtype
from ._extensions._dwt import (dwt_single, dwt_axis, idwt_single, idwt_axis,
                               upcoef as _upcoef, downcoef as _downcoef,
                               dwt_max_level as _dwt_max_level,
                               dwt_coeff_len as _dwt_coeff_len)

__all__ = ["dwt", "idwt", "downcoef", "upcoef", "dwt_max_level", "dwt_coeff_len"]
To unsubscribe from this group and all its topics, send an email to pywavelets+...@googlegroups.com.

Parikshit Bangde

unread,
May 31, 2018, 2:46:27 AM5/31/18
to pywav...@googlegroups.com
Upgrade all library

You received this message because you are subscribed to the Google Groups "PyWavelets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pywavelets+unsubscribe@googlegroups.com.

felixt...@gmail.com

unread,
May 31, 2018, 2:59:49 AM5/31/18
to PyWavelets
Okay, how can I upgrade all library ?

send code in command prompt "pip3 install lib or scipy lib / numpy lib / etc.. " ?
Upgrade all library

To unsubscribe from this group and stop receiving emails from it, send an email to pywavelets+...@googlegroups.com.

Parikshit Bangde

unread,
May 31, 2018, 4:18:34 AM5/31/18
to pywav...@googlegroups.com
Search it on net, it's different for different os 

To unsubscribe from this group and all its topics, send an email to pywavelets+unsubscribe@googlegroups.com.

felixt...@gmail.com

unread,
May 31, 2018, 4:38:05 AM5/31/18
to PyWavelets
Okay, thanks a lot to you

Gregory Lee

unread,
May 31, 2018, 7:34:06 AM5/31/18
to PyWavelets


On Thursday, May 31, 2018 at 2:35:00 AM UTC-4, felixt...@gmail.com wrote:

"Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\Scripts\_dwt.py", line 4, in <module>
    from ._extensions._pywt import Wavelet, Modes, _check_dtype
ModuleNotFoundError: No module named '__main__._extensions'; '__main__' is not a package"

In IDLE Python i use code like this line 1 - 10 

import numpy as np
import pywt

from ._extensions._pywt import Wavelet, Modes, _check_dtype
from ._extensions._dwt import (dwt_single, dwt_axis, idwt_single, idwt_axis,
                               upcoef as _upcoef, downcoef as _downcoef,
                               dwt_max_level as _dwt_max_level,
                               dwt_coeff_len as _dwt_coeff_len)

__all__ = ["dwt", "idwt", "downcoef", "upcoef", "dwt_max_level", "dwt_coeff_len"]




The imports from ._extensions is the source of your problem.  You cannot do this type of relative import from your main python file (This is true for python in general, not just for PyWavelets).  It should work if you write it as:

from pywt._extensions._pywt import Wavelet, Modes, _check_dtype
from pywt._extensions._dwt import (dwt_single, dwt_axis, idwt_single, idwt_axis,
                               upcoef as _upcoef, downcoef as _downcoef,
                               dwt_max_level as _dwt_max_level,
                               dwt_coeff_len as _dwt_coeff_len)
 
but ideally, you should instead instead import the functions you need directly from the public namespace  (e.g.  from pywt import dwt, Wavelet).   The underscores in _extensions indicate that this submodule is "private" and should not need to be imported directly by the user.  It is probably easiest to just "import pywt" and then you can use the functions as pywt.dwt_max_level, etc.



felixt...@gmail.com

unread,
May 31, 2018, 9:32:55 AM5/31/18
to PyWavelets
Oh sure, thanks a lot to you

I already delete that code, and that works


from ._extensions._pywt import Wavelet, Modes, _check_dtype
from ._extensions._dwt import (dwt_single, dwt_axis, idwt_single, idwt_axis,
                               upcoef as _upcoef, downcoef as _downcoef,
                               dwt_max_level as _dwt_max_level,
                               dwt_coeff_len as _dwt_coeff_len)

and i run again, it's not error and it shows like this 

>>> dwt
<function dwt at 0x06D9C8A0>
>>> idwt
<function idwt at 0x06D9C8E8>
>>> downcoef
<function downcoef at 0x06D9C930>
>>> upcoef
<function upcoef at 0x06D9C978>
>>> dwt_max_level
<function dwt_max_level at 0x02FA0150>
>>> dwt_coeff_len
<function dwt_coeff_len at 0x02FA0588>

Do you know about this ? 
The means " dwt_coeff_len at 0x02FA0588 " ?

Gregory Lee

unread,
Jun 1, 2018, 2:30:49 PM6/1/18
to pywav...@googlegroups.com
On Thu, May 31, 2018 at 9:32 AM, <felixt...@gmail.com> wrote:
Oh sure, thanks a lot to you

I already delete that code, and that works

from ._extensions._pywt import Wavelet, Modes, _check_dtype
from ._extensions._dwt import (dwt_single, dwt_axis, idwt_single, idwt_axis,
                               upcoef as _upcoef, downcoef as _downcoef,
                               dwt_max_level as _dwt_max_level,
                               dwt_coeff_len as _dwt_coeff_len)

and i run again, it's not error and it shows like this 

>>> dwt
<function dwt at 0x06D9C8A0>
>>> idwt
<function idwt at 0x06D9C8E8>
>>> downcoef
<function downcoef at 0x06D9C930>
>>> upcoef
<function upcoef at 0x06D9C978>
>>> dwt_max_level
<function dwt_max_level at 0x02FA0150>
>>> dwt_coeff_len
<function dwt_coeff_len at 0x02FA0588>

Do you know about this ? 
The means " dwt_coeff_len at 0x02FA0588 " ?

 
I think your installation is working. Those hex codes like 0x02FA0588 just indicate the address in the computer's memory where the functions are located.  To actually use them you need to pass in appropriate arguments. 

Try looking through some of the examples that are available at

A specific case that plots the outputs of multilevel DWT or SWT transforms is:


 

felixt...@gmail.com

unread,
Jun 2, 2018, 10:57:41 AM6/2/18
to PyWavelets
Okay, i will try that. thank you very much for your help sir :D
Reply all
Reply to author
Forward
0 new messages