Using pygame via Sublime Text on mac 10.8 [duplicate] - python-2.7

This question already has answers here:
pygame installation issue in mac os
(5 answers)
Closed 2 years ago.
I'm using Python 2.7 32 bit and have a few questions about pygame on mac.
Where do the files go when you install it? I'm not given a choice for the file path when I install it.
When I import pygame in IDLE everything works fine (except it's a bit slow to load sometimes), but when I import pygame and run Python using Sublime Text (what would this be called, the key board short-cut is command-b for build), it can not find pygame. I'm assuming I have to find the library and move it to a different place but I can't find it.
When I run a file that imports pygame in the terminal everything works out fine too. Maybe there's a better text editor to use?
I'm new to programming and I'm realizing that its probably a good idea to get more acquainted with how my mac works/ is organized. Any good resources for this?

Just go to Tools->Build System->New Build System and make sure the json file that pops up looks exactly like this:
{
"shell_cmd": "python2.7-32"
}
Save it as "python2_32.sublime-build" or something that lets you know what it is, then you can go to tools->Build System and select your new build directive. Now when you Command-B, your code should run fine.
This essentially lets sublime text know that you want to run this script using the 32 bit version of python (which supports pygame). It's like a shebang for sublime.
Good luck!

Related

SwiftUI absolute beginner on 10.14.6

I installed XCode and opened a new project using SwiftUI but for the following reason it is impossible to run the builded application. I did use the default code and press run.
I get the following message : "minimum deployment target. Change your project’s minimum deployment target or upgrade MacBook ...".
I tried to change the deployement target but immediately I have several Swift Compiler Error like this one : "'some' return types are only available in macOS 10.15.0 or newer"
I'm running a MacBook Pro with 10.14.6. Is there a way to find the source code for a buildable SwiftUI application on my computer ?
I cannot update to 10.15.0 so I'm looking for other advice or explanation. Maybe for some sourcecode I could use on my MacBook compatible with the Swift Compiler I have.
Thanks.
Thanks for your answers. I cannot update my OS and XCode won't build anything if I don't install Catalina first. I was hopping for an other solution, your answers helped me to focus on the right directions so I searched the web a little bit more and read articles on Mac OS X GUI Programming.
I'm now looking at Python : https://wiki.python.org/moin/GuiProgramming
I'm a little bit disappointed because I wanted to start something new with Swift. But, there is a good lesson here, and I'll do with what is possible given what I have :) Back in the days, for GUIs, I've used Web UI, Java and Qt and I was hoping for something new. I guess that I'll pursue my search to create nice and awesome native Mac OS X application both later and on the side.
Thanks.

How do I get Wand for the Raspberry Pi?

I am trying to learn more about displaying graphics with Python 2.7.9 and one post on StackOverflow directed me to wand, but nowhere can I find how to install wand. 'sudo apt-get install wand' fails with 'Unable to locate package wand'.
http://docs.wand-py.org/en/0.4.4/ says to install using '$ sudo apt-get install libmagickwand-dev' but any sample programs end in error with "no module named wand."
What I am trying to do is to flash a number on the console screen that is readable from across the room. I am making an Easter Egg hunt game in Python which is mostly finished, but the numbers on the screen from print ("5") are just too small. My thought was to just use Photoshop to make an image of the number then something like wand to display it instead of printing it to the screen.
So if Wand isn't the correct answer, suggestions would be appreciated. If wand will work for my game display, how do I get it?
Thanks
You can also try pygame if you are doing game display. I tried it and it is very simple to learn. It is normally already downloaded on most python interpreters but if you for some reason do not have pygame, then go here; it teaches well and can help installing:
https://inventwithpython.com/pygame/chapter1.html

Using pypy instead of psyco

Hi I am trying to make use of pypy on my Python 2.7 application running in windows XP.
Just read a little on psyco and it seems pretty easy to use see http://psyco.sourceforge.net/psycoguide/node8.html
if __name__ == '__main__':
# Import Psyco if available
try:
import psyco
psyco.full()
except ImportError:
pass
# ...your code here...
However I realised that psyco doesn't support python 2.7, shame, so pypy being the new hotness, I was wondering how to make use of it in my application. I can't seem to see how I "import" it and make it work as the example above.
My application is not just a single .py file but an entire text editor I am writing using pyqt, I would very much like to speed things up.
Any suggestions of how to use pypy similar to the above code
Any alternatives that would allow me to do something similar to the above?
Many thanks
I just want to clarify, maybe it wasn't clear earlier. currently i use py2exe to create an executable of my application. I have a setup.py file and I run python setup.py py2exe, this creates the executable that I distribute. Now I want to speed up the application so that when I distribute it, the entire application runs faster.
Now how do I make use of pypy again to create a faster executable application that I can distribute?
Pypy is run instead of the CPython executable.
So, when you up until now ran
python mypythonfile.py
Or similar, with pypy you just run
pypy mypythonfile.py
It is a drop-in replacement. You do not need to import anything, especially not psyco

Build systems in Sublime Text

I'm just beginning to learn programming (on C++ and Python), and by beginning I mean total beginning ("hello world" beginning...). Not wanting to use multiple IDE's, I would like to be able to code and build–simple–programs with my text editor, Sublime Text 2. Could someone indicate me, with a step-by-step tutorial, how to implement C++ and Python compiling and executing capabilities in Sublime Text.
I've searched Sublime Text build systems on the site, but the answers are very specific and can't help a rookie like me (but they'll probably help me later).
Thanks
Sublime Text 2 already comes with scripts for building and running Python and C++ programs.
Simply press Cmd+B (or Ctrl+B on Windows & Linux) when a .py or .cpp file is open. The Python file will automatically execute and show the result in the built in console.
For C++, you need to press Cmd+Shift+B (Ctrl+Shift+B on Windows & Linux) to run it after building.
You need to have Python installed (get it here for Windows), and also a C++ compiler. The build system for C++ tries to call g++ by default (get it here for Windows. Remember to select the C++ compiler when installing!).
You will need to add the directories to path (c:\python32\ or similar for python, c:\mingw\bin or similar for the C++ compiler).
On windows, you may experience problems running the C++ programs (it tries to use bash). But Ctrl+B builds the program, and you can then use a command line to run it. Python works flawlessly on Windows.
windows(install minigw, python2.7 and added to the system path)
cpp:
build: ctrl+b
run: ctrl+shift+b
python:
build and run: ctrl+b
you may try to learn the the .sublime-build files in your Tools -> Build system -> New build system
So, you don't want to use an IDE but then you want IDE features from a text editor? :)
Most people who use a text editor for writing code use terminal to build and run the code.
So, for C++, the instructions are:
make (or gcc myprogram.c)
./myprogram
for a Python program, it's even simpler:
python ./myprogram.py
If you're not comfortable with terminal, then you probably need an IDE.
for c++ I actually made sublime to produce colorful error messages which are easier to read and you can also click on the errors which takes you to the file with the error.
You can look at how I modified the build to do what I wanted in here

How can i use /usr/bin/clj conveniently? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Clojure REPL readline like support
I am a clojure newbie. Today i installed it on my Arch box.
%pacman -Q|grep -i jdk
openjdk6 6.b22_1.10.3-1
%pacman -Q|grep -i clojure
clojure 1.2.1-2
clojure-contrib 1.2.0-3
then i run clj:
%clj
Clojure 1.2.1
user=> (+ 1 2)
3
All seems ok however i feel it is VERY difficult to use the clj interactive environment, where i cannot use
arrow key and so on.
What i really want to know is how i can config the clj interactive environment ?
Don't use repl via the command line, install any one of the ide plugins, emacs vim eclipse etc. they all come with integrated repl that way you can directly send statements from your source files to the repl. Plus all of them supports arrow keys history etc. (emacs does)
You already got two nice answers in comments, but this seems like a good chance to plug one of my projects, ClojureX:
https://github.com/citizen428/ClojureX
While developed for conveniently using Clojure on MacOS X, it also works well on Linux and even Windows with Cygwin. It will use rlwrap if it finds it installed and will fall back on the included JLine otherwise.