tony1812
Posts: 354
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

wx issue

Thu Feb 01, 2018 1:13 pm

Hello, I apt installed wx python. but nothing I am really puzzled. I have tow scripts, both have import wx on top. one script import wx with no issue. But the other one keeps complaining that

Code: Select all

Traceback (most recent call last):
  File "/home/pi/Desktop/myLayout.py", line 6, in <module>
    import wx
  File "/home/pi/Desktop/wx.py", line 1, in <module>
    from wxPython.wx import *
ImportError: No module named wxPython.wx
First, why are the two script written the same way one can import wx, the other can't?
Second in my script nowhere I did from wxPython.wx import *, where did this come from?

Thanks

pcmanbob
Posts: 6445
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: wx issue

Thu Feb 01, 2018 1:27 pm

Do you by any chance have a file called wx.py in /home/pi/Desktop/ that is some python program you have created ?

because it looks like you are trying to import wx from the wx.py file.

if your python program is called wx.py try changing its name to some thing else.
Last edited by pcmanbob on Thu Feb 01, 2018 1:29 pm, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
paddyg
Posts: 2332
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: wx issue

Thu Feb 01, 2018 1:27 pm

Using any 'special' names such as 'int' or 'wx' as file names is a sure way to produce indecipherable error messages such as 'no module named ...'
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

tony1812
Posts: 354
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

Re: wx issue

Thu Feb 01, 2018 4:15 pm

Oh I see. I didn't realize the file name matters.
Thanks.

Return to “Python”