wx.App (wxPython) crash when calling - python

Recently I installed wxPython to do some works under Windows. Most of the time I work in Linux so I have a little experience here.
with python.exe interpreter, I just do 2 line of codeimport wxtmp=wx.App(False)
Then the interpreter crashed with Windows error reporting.
I tried both python 2.7.1 and 2.6.6 with wxPython 2.8.11, all come from their main website, still no luck.
Is there something I must do after install Python in Windows ? I can see that python install just fine and can do some basic job, wxPython library can be load, but can't call wx.App

If you are running that in IDLE, then that is your problem. IDLE and wx don't get along very well because you basically end up with two mainloops fighting each other. Try putting it in a file and then run the file from the command line:
c:\python27\python.exe myPyFile.py
That should work just fine. Otherwise, download the correct wxPython for your Python and OS (32/64 bit), uninstall the current one and install the new one. I've been using wxPython on Windows XP, Vista and 7 with no problems like this.

In case like me somebody will stumble into this question like I did. Recently installed wxpython on two machines, windows 7 and XP. Testing the sample code in simple.py (provided with the wxpython docs-demos installer), running from a python console, I had the following problem on both machines: First import ok, but when I did a reload of the module, python crash.
I added this line in the end of the simple.py file: del app
and that fixed the problem on windows 7 and tomorrow I try it on the XP machine.
Same solution fitted for the XP machine. So, reloading an un-edited module with a reference to a wx.App with a closed gui seem not to be feasable. Killing the reference with a del statement was enough to solve the problem.

I searched for a while and found that this is the problem with wxPython and Python >2.5. Tried many fix with manyfest file but no luck, so I think switch to PyQt is the only solution now.

Related

Blank python IDLE window when opening python file on macOS

For some reason, whenever I try to open a python script that has around ~450 lines of code, IDLE's windows simply appears empty and when I try to run it doesn't run anything either... However, if I try to run a smaller program it works for some reason. Does anybody know how I am able to run a python script on my Mac besides IDLE or how to fix the IDLE window being blank whenever I open a file?
To learn how to run Python Python programs on a Mac, read Chapters 1 and 4 of Python Setup and Usage. Running from an IDLE editor is just one way.
IDLE uses the tkinter module which wraps the tcl/tk GUI framework. Did you read and follow the instructions of how to replace the buggy tcl/tk that Apple supplies? Read the entire page before starting! Ignoring this page is the most common reason people have problems with IDLE on the Mac. There are a few others, but I do not remember one that matches your description.

Tensorflow - running python files in Spyder

to give a bit of background I'm trying to use TensorFlow object detection api. I have been following this tutorial https://www.youtube.com/watch?v=MoMjIwGSFVQ
15 minutes into it he uses Spyder, and runs the python files on it. I've never used Spyder before, and for some reason it's not running my files at all? When I press run nothing is returned on the console.
So can anyone suggest a different IDE that I could use that would allow me to do the same things as he does? Or would anyone be able to tell me why Spyder might not be running. (I installed it in Linux terminal, and simply imported the file as a project as he did, and so I'm a bit stumped as to whats going wrong).
Thanks!

My python installation on 1and1 stopped working (bashrc issue)

I installed python 2.7.10 on my 1and1 linux hosting service about 8 months ago (using instructions from http://geeksta.net/geeklog/python-shared-hosting/) and everything was working fine (I had a daily cron job that would call my python script). But recently,my python script stopped working and it appears that the call to python itself is the culprit, rather than the python code. Whenever I type 'python' into the command line in the 1and1 unix ssh session now, i get the following error message
"-bash: /kunden/homepages/26/xxxxxxxxxx/htdocs/python27/bin/python: No
such file or directory"
It's been awhile since I installed things, but I don't believe I had this issue previously. I'm trying to figure out why it's not working and what I can do to get it fixed. It appears that calling python isn't working properly (which would affect my script as well).
Any help with getting this working would be greatly appreciated.
when you type python, system find it in /kunden/homepages/26/xxxxxxxxxx/htdocs/python27/bin/python, but there is no such a file in fact.
what you need to do is trying to locate your python binary executable file, and alias your python to your file
I ended up just reinstalling python 2.7 again and it works again. Not sure why it stopped working before.
Now I can type "python" in the command line and it starts the Python console.

Problems with different versions of python

Questions similar to this one have been asked but I haven't seen a solution yet that helps me.
I am running Windows 7 and I've installed two versions of python, 3.3 and 2.7. Python 3.3 was the first version I installed and I was able to run scripts from the desktop (not the command line). I installed python 2.7 so that I could get numpy, scipy, and matplotlib down the road, but I found that all the scripts on my desktop defaulted to python 2.7. Since I coded in 3.3 this caused some issues.
I was able to fix this by right clicking the script icon, browsing programs, navigating to the python 3.3 file in my C: drive, and selecting the idle inside that directory. But then I found I wasn't able to run those scripts with python 2.7 using the exact same procedure.
Unfortunately I don't know command-line programming very much at all, and it seemed like most of the answers were geared towards that as a solution. Ideally I'd like to specify which python I want to run a script from the desktop, or possibly while I'm editing the script.
If it's relevant I'm running the eric python IDE, version 5.
I'd be happy to do the work of reading something fairly technical and long (like a blog post or PDF), but it won't help me much if it isn't aimed at beginners.
The Windows Python Launcher can automatically detect the Python from the shebang in your file.
Start your Python 3.3 scripts with
#!/usr/bin/env python3
and your Python 2.7 scripts with
#!/usr/bin/env python2.7
If you want to use the system's default Python version, you can just start the file with
#!/usr/bin/env python
This will also work on virtually all Unix systems.
Maybe you should chose another IDE, like PyCharm, it could manage different versions of python easily (and gives tons of other useful features). Perhaps free PyDev could also make it.
Also, using virtualenv — is the best solution here, but it's a "hard way".
The method I use is to have several cmd.exe shortcuts on my desktop, each pointing at a different runpython.bat file, one for each version of python. Here is one command example from a shortcut:
%comspec% /k "C:\QA\Python\QAPYTH3\runpython.bat"
Here is a typical runpython.bat:
#SET PATH=%PATH%;"C:\Python32"
#SET PYTHONPATH=C:\Python32\Lib
#ASSOC .py=Python.File
#ASSOC .pyc=Python.CompiledFile
#ASSOC .pyo=Python.CompiledFile
#ASSOC .pyw=Python.NoConFile
#FTYPE Python.CompiledFile="C:\Python32\python.exe" "%%1" %%*
#FTYPE Python.File="C:\Python32\python.exe" "%%1" %%*
#FTYPE Python.NoConFile="C:\Python32\pythonw.exe" "%%1" %%*
#SET PATHEXT=.py;%PATHEXT%
Of course you don't have to call your .bat files the same as I have. Just adjust to suite your setup.

How to install python 3.2.3 on Windows 7 enterprise

although I have been using python a long time very easily in a Linux environment, I have tremendous trouble to even install it correctly in a windows environment. I hope this is a question to be asked here, as it is not directly a programming question.
Especially, I have the following problems:
When on the command line, python is not a recognized command. Do I have to set the Windows path manually myself? If so, how to do that?
When starting a python script, should this be done with python.exe or pythonw.exe? What is the difference?
I also tried to install ipython several times, it never got installed (even after following the starting ipythonenter link description here thread.
When starting a script with python.exe, a window pops up and closes immediately. I saw some hints in putting in a readline command, which is of no help if there is a syntax error in the script. So how to be able to keep the window open, or how to run the command on the cmd.exe?
Thank you for any help on these items.
Alex
1) Look here: www.computerhope.com/issues/ch000549.htm
2) It has already been answered, always try to use search before asking question:
pythonw.exe or python.exe?
4) When using cmd.exe just navigate to your script folder using dir for changing directories and C:,D:,etc. for changing drives. Then run script by typing just the script name. When installed correctly, Python automatically launches .py scripts with python, so you don't have to write 'python' before script name. When run in cmd, window will stay open. If you want it to stay open even when launching script with double-click, use function waiting for user input, see here How to keep a Python script output window open?
You might want to use Python3.3, there is a new launcher for Python scripts in it. By that, you can start Python scripts with py <scriptname> which has the benefit of being installed in your path (C:\Windows\system32) and you can use a shebang to tell whether the script is for Python2 or Python3.
Also
In addition to the launcher, the Windows installer now includes an
option to add the newly installed Python to the system PATH
(contributed by Brian Curtin in issue 3561).

Categories