Interaction between pygame and python

2016-03-14 Thread Tyson
I am having a lot of trouble getting python to find the pygame module; my
operating system is Windows 7.  Can you  offer any help?  . Should I
download pygame into the same folder as Python? . any ideas at all?

 

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit
(Intel)] on win32

Type "copyright", "credits" or "license()" for more information.

>>> import pygame

Traceback (most recent call last):

  File "", line 1, in 

   import pygame

ImportError: No module named 'pygame'

>>> import pygame, sys

Traceback (most recent call last):

  File "", line 1, in 

import pygame, sys

ImportError: No module named 'pygame'

>>> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Python 3.3 can't find PySide

2013-01-12 Thread Tyson Moore

Hi everybody,

I'm just starting to dabble in Python development after spending years 
with C# and Java, but there's one small thing holding me back: I can't 
seem to get PySide working for the life of me. Let me explain:


I'm on OS X 10.6.8 and have installed Python 3.3.0 and Qt 4.8.4 with 
Homebrew. The Python interpreter works fine, and all the Qt utilites 
are in my $PATH and installed correctly. Homebrew has a package for 
PySide, but it's only compiled against Python 2.x instead of 3.x (there 
is an issue about this, https://github.com/mxcl/homebrew/issues/16439), 
so I can't use that.


I tried using the PySide BuildScripts on GitHub, but those fail with an 
error that I can't seem to resolve (I'll save that for a PySide list, I 
guess). I can't compile it manually because I don't have the expertise 
to pass the right options to cmake and tell it where to find all my 
Python stuff, so I'm really at my wit's end.


I tried installing the Homebrew PySide package anyways, but putting the 
PySide directory (with __init__.py) in my PYTHONPATH didn't allow me to 
import anything from PySide; I guess this means that PySide has to be 
told to compile for 3.x instead of 2.x.


My question: is there anybody who has had success installing PySide on 
OS X for Python 3.x? There must be a way, I must be missing 
something... right?


I'll try to find a more relevant PySide list or something to pose this 
question on but in the meantime, if anybody has any suggestions, I'd 
appreciate your input. Thanks in advance!

--
Tyson Moore
tyson+use...@tyson.me

--
http://mail.python.org/mailman/listinfo/python-list


Re: Subprocess module: running an interactive shell

2009-03-15 Thread Joe Tyson

On 2009-03-14 20:10:29 -0400, Karthik Gurusamy  said:


On Mar 14, 3:03 am, Roman Medina-Heigl Hernandez 
wrote:

Karthik Gurusamy escribió:




On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez 
wrote:

Hi,



I'm experimenting with Python and I need a little help with this. What

 I'd

like is to launch an interactive shell, having the chance to send firs

t

several commands from python. I've written the following code:







#!/usr/bin/env python



import sys, subprocess



exe = "/bin/sh"
params = "-i"



-i says shell to be interactive. So looks like it is directly trying
to read from the terminal.


Well, then the question will be: is there any way to tell python to
directly "map" the terminal to the subprocess?


pexpect seems to be the solution for such problems :). [other
applications include ssh which asks for password from terminal (not
ssh's stdin)]

http://pexpect.sourceforge.net/pexpect.html




proc = subprocess.Popen([exe, params], stdin=subprocess.PIPE)



proc = subprocess.Popen([exe,], stdin=subprocess.PIPE)



works for me; but if there is an error 'sh' terminates.



If you want to simulate interactive, explore the pexpect module.


I'll get it a try :)))


proc.stdin.write("id\n")



while True:
        line = sys.stdin.readline()
        if not line:



note that a simple enter terminates the shell which you may not want.


Test my code and you'll see that this is not true :) When you hit enter
line will contain '\n' so it's not empty.


You are right. I thought readline() strips the trailing \n (It doesn't
and shouldn't as it's necessary for the case a file ends without a
newline).




                break
        proc.stdin.write(line)


Btw, another curiosity I have: is it possible to make a print not
automatically add \n (which is the normal case) neither " " (which happen

s

when you add a "," to the print sentence)?  I found an alternative not
using print at all, eg: sys.stdout.write("K"). But it resulted strang

e

to me having to do that trick :)


I am also aware of only the sys.stdout.write solution.

python3.0 has a way to do it.


help(print)

Help on built-in function print in module builtins:

print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout)

Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current
sys.stdout.
sep:  string inserted between values, default a space.
end:  string appended after the last value, default a newline.


print('hello', end='')

hello>>>

Karthik



Thank you for all your comments and comprenhension.

-r




sys.exit()







The problem is that when I launch it, python proggy is automatically
suspended. The output I got is:



ro...@rslabs:~/pruebas$ ./shell.py
ro...@rslabs:~/pruebas$ uid=1000(roman) gid=1000(roman) groups=1

000(roman)

ro...@rslabs:~/pruebas$



[2]+  Stopped                 ./shell.py
ro...@rslabs:~/pruebas$



Why and how to fix it? Would you suggest a better and more elegant way

 to

do what I want?



As I see it, 'sh' is attempting to read from the keyboard and not from
stdin.



Karthik



Thank you.



--



Saludos,
-Roman



PGP Fingerprint:
09BB EFCD 21ED 4E79 25FB  29E1 E47F 8A7D EAD5 6742
[Key ID: 0xEAD56742. Available at KeyServ]



--
http://mail.python.org/mailman/listinfo/python-list


--

Saludos,
-Roman

PGP Fingerprint:
09BB EFCD 21ED 4E79 25FB  29E1 E47F 8A7D EAD5 6742
[Key ID: 0xEAD56742. Available at KeyServ]


There is quite a bit involved in handling this. Check out this recipe 
on activestate:

http://code.activestate.com/recipes/278731/

- Joe

--
http://mail.python.org/mailman/listinfo/python-list