I've spent a very frustrating evening trying to get wxpython to work on my MacBook Pro (running Snow Leopard 10.6.6). From reading the various threads on this topic both here and on other websites this is my understanding so far:
If you are running python 2.6 or greater you can only work with wxpython if you access the 32-bit version
Typing python at the command line prompt reveals that I am using python 2.6.1.
Typing which python returns /usr/bin/python so I'm using the default version installed with my OS. This means that typing the following at the command line prompt
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes should change the version I'm using to the 32 bit version.
With the above in place, I can now simply type the name of my python file (with the wx module imported) and my file will run successfully.
As you can no doubt guess however my file doesn't run successfully. I can't figure out what's going on, but maybe someone else can here are some other observations that might help...
typing help(), modules yields the following message and then prints out the modules, including wx and wxpython
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/pkgutil.py:110: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or actively maintained. Please switch to the wx package as soon as possible.
__import__(name)
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/pkgutil.py:110: DeprecationWarning: twisted.flow is unmaintained.
__import__(name)
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted/python/filepath.py:12: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
import sha
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted/words/im/__init__.py:8: UserWarning: twisted.im will be undergoing a rewrite at some point in the future.
warnings.warn("twisted.im will be undergoing a rewrite at some point in the future.")
Fri Jun 3 22:23:48 Paul-Pattersons-MacBook-Pro.local python[3208] <Error>: kCGErrorFailure: Set a breakpoint # CGErrorBreakpoint() to catch errors as they are logged.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
Then examining the wx module specifially yields...
NAME
wx
FILE
/usr/local/lib/wxPython-unicode-2.8.12.0/lib/python2.6/site-packages/wx-2.8-mac-unicode/wx/__init__.py
Can anyone help?
I don't have a Mac, but I read almost all the messages on the wxPython mailing list. As I understand it, you don't want to use the Python that came with your Mac. It has been modified for the Mac specifically somehow, so you should download a normal version of Python and install it.
As for the 32-bit question, with wxPython 2.8, you are correct. You are limited to 32-bit because of the Carbon API. However, if you scroll down the download page (http://wxpython.org/download.php) you will see that wxPython 2.9 has been released and it has a Cocoa build which (and I quote) "requires at least OSX 10.5, and supports either 32-bit or 64-bit architectures" and Python 2.7.
I highly recommend that you go and seek help on the wxPython mailing list. The author of wxPython is there and he uses a Mac and there are several other Mac addicts on the list too that answer these sorts of questions.
Related
I have a build phase that calls some python scripts.
This has been working fine for well over 2 years, but after recently updating to Xcode 13.3 it now fails.
the error I started receiving is:
/Users/me/Library/Developer/Xcode/DerivedData/MyApp-fsowouspdsdjjzfmlfafizjbkcae/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/Script-9002D8C42166BC850081D43D.sh: line 6: python: command not found
Command PhaseScriptExecution failed with a nonzero exit code
At a glance, it looks like xcode is attempting to run the script on the simulator instead of running in the local project directory.
python --version:
Python 3.8.3
I am wondering if there is some new configuration that I am unaware of for new xcode versions?
EDIT:
when i run the the lines in the script in my terminal, they run just fine.
You have installed Python 3 somehow (brew, perhaps), and it is in your PATH. That is why, when you say python, it is found.
But that same Python is not in Xcode's PATH! And it never has been. You've never noticed this, and you've never needed to notice it, because Xcode has always used the system Python, which was located in /SystemLibraryFrameworks. You and Xcode were probably using different Python versions (the system version stopped at 2.7), but this didn't matter.
But now (Monterey 12.3), it isn't. There is now no Python in Xcode's PATH. Thus, when your script says python plain and simple, it isn't found. You can fix this by using a complete path in your scripts that specifies where your Python is. You can find this out by saying which python.
So, Xcode seems to bundles its' own versions of python and python 3. It does not use the system version, so changes to Monteray 12.3 would not affect this.
Since that is the case, the correct solution is changing python to python3 since it looks like an Xcode update dropped python2.7 to parallel the OS dropping it later. I had to also update my python file to ensure compatibility.
edit September, 2, 2017, 1pm
I eventually managed to build a .exe with pyinstaller after many episodes.
Unfortunately I failed to deal with the ‘theano’ module (that is required in my case by the ‘pymc3’ module) and I had to modify the .py files and give up part of the application. My description below has two aims: first it may help; second could anyone help me building a .exe for windows 7+, with the ‘theano’ module ?
reminder: My python 3 script opens a simple GUI made with Qt Designer in a ‘.ui’ file and imports pyqtgraph (with pyqt5), pymc3 (and thus theano that is required by pymc3), scipy, numpy, os, sys. It will be distributed on machines with Windows 7+. I tried to build a ‘.exe’ with py2exe, cx_freeze, pynsist and pyinstaller (I opened and updated several posts, this one is still opened: build a .exe for Windows from a python 3 script importing pyqtgraph and opening a GUI) but all failed. My best result (with pyinstaller) is described below after I had to give up theano.
the command line I ended up with is: pyinstaller —noupx —onefile —add-data “toto.ui;.” toto.py. But strangely:
1 the qt designer file ‘toto.ui’ is not included and must be distributed together with the .exe. Otherwise there is an error message when running the .exe saying toto.ui not found;
2 the ‘platforms’ directory from the ‘Library/plugin’ directory of the python environment must also be distributed along with the .exe. Otherwise there is an error message when running the .exe ‘this application has failed to start because it could not find the qt
platform plugin windows’ (but there is no error message from pyinstaller when building !)
3 the .exe is 220MB big ! it seems pyinstaller includes a bunch of useless things during the building.
pyqtgraph problem:
At first sight, the module ‘pyqtgraph’ seems to be incompatible with pyinstaller. Indeed, when the python code imports pyqtgraph, pyinstaller gives a SyntaxError: ‘yield’ inside async function. This seems to me very awkward (is this a bug in pyinstaller ?) because I had the impression from forums this is related to asynchronous generators that are only compatible with python 3.6, while pyinstaller works only with python 3.5- that is not compatible with asynchronous generators… so why does pyinstaller use this ? It turns out this bug-like feature is disabled in a new version of pyinstaller that is not released (and so not installed by default): pip install git+https://github.com/pyinstaller/pyinstaller, thanks to 9dogs (in comments). I also found it may help to explicitly write os.environ[‘PYQTGRAPH_QT_LIB'] = 'PyQt5’ or ‘PyQt4’ before importing pyqtgraph in the py file(s)
theano problem:
theano turns out to make several implicit imports that are not detected by pyinstaller. Thus the building looks ok but when running the .exe you get error messages like ‘no module theano.tensor.shared_randomstreams’. Unfortunately I failed to use the '--hidden-import' option of pyinstaller so I added explicitly the imports in the py file(s) (in this example ’import theano.tensor.shared_randomstreams’ ).
But this is not the end: after that, the file ‘…\AppData\Local\Temp_MEI35682\theano\gpuarray\blockgemv.c' is missing, leading to [4128] Failed to execute script. I don’t know what this file is and didn’t find information. I gave up and removed part of the GUI to avoid theano. Can anyone help me using theano with pyinstaller ?
I want to build a Darwin Streaming Server on my mac for iOS development test. But after taking the following steps which I searched from google, it fails all the time.
Method 1:
Download from http://dss.macosforge.org/ ->Mac OS X Install -> Streaming Server;
Install the dmg;
It tries to open http://127.0.0.1:1220/ but fails with "This webpage is not available ERR_CONNECTION_REFUSED".
Method 2:
Download the source code of 6.0.3 version;
$ tar xvf DarwinStreamingSrvr6.0.3-Source.tar
$ cd DarwinStreamingSrvr6.0.3-Source
$ wget http://www.abrahamsson.com/dss-6.0.3.patch
$ patch -p0 < dss-6.0.3.patch
$ ./Buildit
Then, it fails with the following words.
Darwin Streaming Server
I don't know your platform. I'll assume this is a Linux x86 platform.
Please edit the BuildServer script & PlatformHeader.h to add your platform.
Building for Darwin.x86_64 with gcc
xcodebuild DarwinStreamingServer
=== BUILD LIBRARY TARGET AtomicLib (Library) OF PROJECT StreamingServer WITH CONFIGURATION Development ===
Check dependencies
Jam is deprecated and has been removed; targets that use Jam must be upgraded to native targets. For more information on doing this, consult the Xcode documentation.
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)"
I tried to run ./Install, it showed me
Unable to perform install
You must be logged in as root to install Darwin Streaming Server
and I don't know what to do now.
PS: I've installed Xcode on my mac and didn't find any available document about Darwin Streaming Server, or I missed it?
Hope for any help. Thanks.
Calios and Jessica, thank you for your answers. I'm running using OS Windows 7 and installing DSS 5.5.5 for windows, and I also meet the condition same as with you.
However, after I followed your instructions, it's not close enough with our needs, because the button will lose meaning in presentation.
So I started digging more information from another articles, and I found interesting perception from a developer at this article. He said the following:
Maybe this has something to do with the perl script which generates the web sites?*
So starting from Jens's perception, I tried to downgrade my Perl Script from version 5.26 to 5.8. This resolved my problem, the interface displays correctly as in the DSS Tutorial.
Right now I'm still working on testing the DSS function
I hope this solution will help others.
Well, finally I solved this issue with the help of my friend.
Here's the steps of solution.
I've given up compiling and building on my own and downloaded the dmg file.(version 6.0.3)
Install the dmg as directions.
Then, go to /usr/sbin in terminal and find streamingadminserver.pl and QuickTimeStreamingServer.
Run them.
Check if they're running with ps aux|grep streaming.
Open http://localhost:1220/parse_xml.cgi in Safari or Chrome. It will show some textfield and a button.
However, there's no words at all ! Go to /Library/QuickTimeStreaming/AdminHtml and edit setup_assistant2.html.
Find line 333 and change it from return "$message{$name}"; to return $name;.
Then it shows some understandable words, though not exact words.
Till now, it can be partly work. However, in some steps I mentioned above, for example, html editing step, I really don't know why the words just don't show and just have a try.
Save the exact steps I did here for memory. It will be wonderful if it can help anyone or anyone have some good idea about it.
Thanks.
#SouravGupta, I am a newbie for stackoverflow, so I could not add comment to reply your question.
I just installed DDS 6.0.3 on Mac OS X El Capitan. I hit the same problem you had. I found that ** return "$message{$name}"; ** is no longer in setup_assistant2.html. It is in parse_xml.cgi (/Library/QuickTimeStreaming/AdminHtml). Just search for "sub foundString". There were two return places there. You need to change both in order to make it work.
It seems that DDS web admin software has localization function. Html files only contain string keywords. It suppose to use that "foundString" function to get translated string from keywords. However, for some reason, it returns empty string here even if there is a "messages" file inside html_en folder. I could not spend more time to figure out why right now.
QTSS/DSS Web Admin 6.0.3 requires Perl version 5.16 and earlier. OS X 10.11 El Capitan installs both Perl versions 5.16 and 5.18, but it defaults to using Perl version 5.18.
In order to run QTSS/DSS Web Admin in OS X 10.11 El Capitan, you need to examine each of the Perl script (.pl) within the AdminHtml folder and change the line #!/usr/bin/perl to #!/usr/bin/perl5.16.
This is more like a beginner's question.. So please bear..
I started using the google app launcher - python, I created a new application with port 8080. When I run the default Hello, World application (which i noticed from main.py)
I always keep hitting the 500 error - Internal server.
I find this kind of strange error in the logs:- ImportError: No module named urllib.
I'm stuck.. Can you please help trouble shoot.
Thanks!
P.S: I run a snow leopard with a python 2.6.1 pre-installed, hence I didn't install a new package.
I resolved this by the following:
Installed python 2.7.3 from the python site.
Adding the python path /usr/local/bin/python2.7 in the google app launcher preferences.
Hitting the return key after typing the path and then closing the preferences.
Restarting the application and tadaaa.. :)
I've seen this too -- in fact, one of my OS X boxes still has this problem sometimes. I believe there is probably something in your .profile or site-packages that causes this, but it's difficult to debug. You could try installing Python 2.7 from python.org and use that. (Sorry for being so vague.)
Using the Python templates for Xcode, I have a simple project running on one machine and failing on two others, for different reasons. The failure I solved is that even though main.m has:
Py_SetProgramName("/usr/bin/python");
The actual running Python as seen from main.py with this:
import sys
print sys.version
is different. And the problem was that this other Python didn't have objc installed. So the question is: short of cleaning up my machine, how can I direct Xcode to use the system Python?
Edit:
This is a problem that seems like it is trivial, but it isn't. It seems so because when I specify Mac OS X 10.5 as the Base SDK, Xcode links against that Python.framework, as I can see by double-clicking the icon in Linked Frameworks in the Xcode project.
Each Version in Python.framework has a key/value pair in its Info.plist: CFBundleExecutableName/Python. Luckily (for the forensics) this Python in the Version 2.5 framework launches 2.6.1! Yet by printing sys.version (from main.py) or by snooping on the loader (by doing export DYLD_PRINT_LIBRARIES=1), I can see that the PyObjC App actually launches Python 2.5.4.
The line above with Py_SetProgramName.. is irrelevant---it can be commented out and everything works fine.
So what it looks like is that Python.framework controls which Python is launched, it doesn't do this in the way I expected, and it might be controlled through an initialization routine that is opaque, since it's controlled by Apple. It seems the best way to "control" the situation is to change the Base SDK.
Sorry to answer my own question but I was just confused. This part is an error
Python in the Version 2.5 framework launches 2.6.1
caused by my not realizing that what's going on here (from the Version/2.6 directory)
> ./Python
-bash: ./Python: cannot execute binary file
> Python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
is that we're searching my $PATH and launching /opt/local/bin/python.
Apologies for the confusion.
To summarize, setting the SDK should get the desired Python to run as we can see by snooping on the loader:
> export DYLD_PRINT_LIBRARIES=1
> ~/Desktop/X/build/Debug/X.app/Contents/MacOS/X
dyld: loaded: /Users/telliott_admin/Desktop/X/build/Debug/X.app/Contents/MacOS/X
dyld: loaded: /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
dyld: loaded: /System/Library/Frameworks/Python.framework/Versions/2.5/Python
..