What special setup does Pycharm pygame need?

Hi
I have all the pycharm files in my
Macbook's OS X 10.9.5

/developer/python
folder
Does Pycharm need any special steps done to link the files into its functionality?
How do I make it so that the
import pygame
works?

Thanks
LVL 1
beavoidAsked:
Who is Participating?
 
gelonidaCommented:
I know neither the .mpkg file suffix nor System python.

Normally a binary package for python 2.7 is compatible with python 2.7.0 - 2.7.99 on the same platform.

But we seem to touch Mac specifics where I can't help.

In the youtube link, that you posted her they tried to show you how to install:
- Xquartz
- python 3
- gcc
- some binary libraries
in order to use afterwards the command pip3 for installing pygame


Perhaps you could try following:
try to find out whether there is a python 2.7 package that can be installed and change the installation order like this:
- install gcc
- install SDL
-install python 2.7
- install XQuarz
- install python3 if you like to
use pip install pygame to install for python 2.7
use pip3 install pygame to install for python3

As said before I can't try this (not having a Mac) but this would be the suggested order.

I stringly propose to posta a new question where you ask about installing

python 2.7 and or python 2.3 and XQuarz as this will help you to continue here.
0
 
gelonidaCommented:
I don't use any framework, so I can't help.
Hopefully others know more.

Normally however you should not need anything special if you installed pygame
on the same python, that is used by Pycharm
0
 
gelonidaCommented:
you can test following script to find out whether pygame is in the search path and can be imported
import sys
print("My python is %r" % sys.executable)
import pygame
print("and I managed to import pygame")

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
beavoidAuthor Commented:
pygame is underlined red, and that is the point. The search path must be incorrect.
0
 
gelonidaCommented:
apart from the underlining.

a few  questions:
1.) What is exact output of my above script?

2.) How did you install pygame?

3.) does pygame work from the command line (without pycharm)?
0
 
beavoidAuthor Commented:
Thanks

1) Exact Output in pyCharm :

/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 /Users/jameshancock/PycharmProjects/untitled/EEpyCharm.py
My python is '/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3'
Traceback (most recent call last):
  File "/Users/jameshancock/PycharmProjects/untitled/EEpyCharm.py", line 3, in <module>
    import pygame
ImportError: No module named 'pygame'

Process finished with exit code 1



2) pygame install : I clicked on the .dmg file and let it do its install thing.

3) In Python 3.3.3 shell, I get :

>>> import sys
>>> import pygame
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    import pygame
ImportError: No module named 'pygame'
>>> 

Thanks
0
 
gelonidaCommented:
Not knowing Mac and the dmg image. and the amount if information printed out during the install phase:

Could it be, that the pygame.dmg is for python2.7 ? and that you have different versions of python installed on your machine?
0
 
beavoidAuthor Commented:
Experts,

Is gelonida correct?

I have Python 3.3

And my install .dmg is

pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3-3

Is the problem that this .dmg is for py 2.7 ? what is the 10.3-3 in the filename?

What is the location of the best install .dmg for me?

I have Mac OS X 10.9.5
Thanks
0
 
gelonidaCommented:
the file name very strongly suggests, that you installed pygame for python 2.7.
so it will not be usable by python 3.3

you need an exact match of the two first version numbers.


You had to look for a file with a name like
pygame-1.9.1release-python.org-32bit-py3.3-macosx??.?-?

even
pygame-1.9.1release-python.org-32bit-py3.4-macosx??.?-?
wouldn't match

the first two version numbers must match
0
 
gelonidaCommented:
Out of curiousity yu could use your file explorer and check in the directory
/Library/Frameworks/Python.framework/Versions/
how many directories you find.
You should have the folder with the name "3.3" there.
Do you also have a foldernamed "2.7" ?
If yes, then check whether you find the file
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

you could then start this from trom a console window
and try
import pygame

Open in new window



I personally don't have access to a Mac and work mostly from the command line.
So if you need precise help about how to install python 2.7 and 3.3 (or even better 3.4) in parallel and how to use them with Pycharm and Mac I'd suggest to post another question and let you help

If you can I would install python 2.7 AND python 3.4 on your machine.
This should allow you to use python 3.4 for most new projects and python 2.7 for projects that depend on libraries, that haven been ported to python 3.4 so far.

If you follow a few coding guide lines and if you use the module six you will be able to write code, that will run under python 2.7 AND 3.4
0
 
beavoidAuthor Commented:
This is Mac Os X
No folders 2.7 or 3.3

I can't find a Mac download Python 3.3 for my operating system, Os X Snow Leopard. 10.9.5

Does anyone have pygame working?
Which versions, and what Os's?

Thanks
0
 
gelonidaCommented:
Hmm, I'm no Mac user, but in one of your previous posts you wrote:
1) Exact Output in pyCharm :

/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 /Users/jameshancock/PycharmProjects/untitled/EEpyCharm.py

So there MUST be somewhere on your system a directory corresponding to python 3.3:
and I would expect it to be /Library/Frameworks/Python.framework/Versions/3.3

So if you had python 2.7 installed in a similiar way I would expect it to be located in
 /Library/Frameworks/Python.framework/Versions/2.7

Probably pygame still doesn't exist for python 3
so you had to install python 2.7
In any case it is a good idea to have python 2.7 and python 3.3 (or even better python 3.4) installed.

There are still some good projects out there that are not supported by python 3.

However I do not know how to install mulitple versions of python on Mac and use both of them with pycharm (depending on the project)

Perhaps you had to ask somebody else to get help for this.
0
 
gelonidaCommented:
Just for your info.
The pygame FAQ states:
Does Pygame work with Python 3?

Yes. Pygame 1.9.2 supports Python 3.2 and up. Only the orphaned _movie module (not built by default) does not.
But don't know here you can download a package for Mac and 3.3.
0
 
beavoidAuthor Commented:
Thanks
How will PyCharm know what has been installed?
and "here" - were you meaning to give a link to the download?

Is that for IDLE ?
How do I make it work in PyCharm?
0
 
gelonidaCommented:
That was a typo:
here -> where

So I do not know where to find pygame for python 3.3 :-(

Did you manage to locate your currently installed python version with a file explorer or a shell window?

To summarize if you want to use pygame you have to either find how to install
pygame for python 3.3 (find the appropriate installer)

or to install pyhton 2.7, install pygame for it and then select python 2.7 with pycharm.

I don't use Mac and don't use pycharm. But I expect, that pycharm allows you to configure which python interpreter to use (as soon as you managed to installl python 2.7 or as soon as you found its location if it is already installed)

you could open a shell window and type following commands.
what youtput do you get:
which python
which python3
which python2

Open in new window

0
 
beavoidAuthor Commented:
Thanks

Typing these into Python 3.3.3 shell gives..

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 16 2013, 23:39:35) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.
which python
SyntaxError: invalid syntax
>>> which python
SyntaxError: invalid syntax
>>> which
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    which
NameError: name 'which' is not defined
>>> 

Open in new window

0
 
gelonidaCommented:
I was talking about an operating system shell: (bash / zsh / ksh or csh )
Could you retry from a system shell?
0
 
beavoidAuthor Commented:
Thanks, I get this output from bash:

Last login: Wed Apr 22 09:18:56 on ttys000
Jamess-MacBook-Pro:~ jameshancock$ which python
/usr/bin/python
Jamess-MacBook-Pro:~ jameshancock$ which python3
Jamess-MacBook-Pro:~ jameshancock$ which python2
Jamess-MacBook-Pro:~ jameshancock$ 

Open in new window

0
 
gelonidaCommented:
could you please send the output of  following four shell commands
python -V
ls -l /usr/bin/python
ls -l /Library/Frameworks/Python.framework/Versions
ls -l /Library/Frameworks/Python.framework/

Open in new window


I'd like to find out whether you have one or multiple python versions installed on your system
0
 
beavoidAuthor Commented:
Thanks . . . . .


Jamess-MacBook-Pro:~ jameshancock$ python -V
Python 2.7.5
Jamess-MacBook-Pro:~ jameshancock$ ls -l /usr/bin/python
-rwxr-xr-x  2 root  wheel  58608 Sep  7  2014 /usr/bin/python
Jamess-MacBook-Pro:~ jameshancock$ ls -l /Library/Frameworks/Python.framework/Versions
total 0
drwxrwxr-x  9 root  admin  306 Nov 17  2013 3.3
Jamess-MacBook-Pro:~ jameshancock$ ls -l /Library/Frameworks/Python.framework/
total 24
lrwxr-xr-x  1 root  wheel   24 Jan 21  2014 Headers -> Versions/Current/Headers
lrwxr-xr-x  1 root  wheel   23 Jan 21  2014 Python -> Versions/Current/Python
lrwxr-xr-x  1 root  wheel   26 Jan 21  2014 Resources -> Versions/Current/Resources
drwxr-xr-x  3 root  wheel  102 Nov 17  2013 Versions
Jamess-MacBook-Pro:~ jameshancock$
0
 
gelonidaCommented:
/usr/bin/python -V shows you, that you have a version of python 2.7 installed on your machine
and that it's located at /usr/bin

ls -l /Library/Frameworks/Python.framework/Versions shows you that below this directory you have only Python 3.3 installed.


Now we can check whether pygame was installed for your pyhton 2.7.

just enter following command:
/usr/bin/python -c "import pygame.version; print pygame.version.ver"

Open in new window

and look at the output.

If this works, then the next question is how to configure a pycharm project to use /usr/bin/python instead
of /Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3.

I would ask another question of it.
So far I never used pycharm nor Mac, so probably you need somebody elses help.
0
 
gelonidaCommented:
Well I just installed pycharm for fun on my windows PC

In your project settings you can choose the python interpreter.

File -> Settings -> Build/Execution/Deployment -> Console -> Python Console -> Python Interpreter
You should be able to choose a python interpreter.
Does it allow you to choose between
/usr/bin/python
and
/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 ?
0
 
beavoidAuthor Commented:
On a Mac, there is no Settings option in the file menu, you have to enable it in the toolbars menu..and it is an icon on the toolbar or simply press (Ap , )  Ap-Comma
I can choose as my interpreter

3.3
2.7
2.5
2.6
A ton of 3.0.4 versions
and lastly, a 3.8.0  -  4.1.2

Thanks
0
 
beavoidAuthor Commented:
Hi
Found this on Youtube.

Will this be enough - exactly correct? here
0
 
gelonidaCommented:
Well the instructions look OK, though I can't test them

Notice that this will probably install another version of python 3 than the one, that you have installed.
his procedure is a little more complicated as you have to install the gcc compiler and quite some libraries.
The advantage of this suggestion is, that you will then be able to compile pycharm for your given python version by typing "pip install pygame". It will also allow you in the future to compile other python modules for which you don't find precompiled binary packages.

After installing all this retry from a system shell window the commands

which python
which python3
which pip3

Open in new window


You have to make sure, that pycharm will use the correct version of python.


By the way. Did you try the command
/usr/bin/python -c "import pygame.version; print pygame.version.ver"

Open in new window

as I suggested in one of my previous mails?
0
 
beavoidAuthor Commented:
Yes, I did, it doesn't print anything.

but I do get this version confirmation !

Jamess-MacBook-Pro:~ jameshancock$ python -V
Python 2.7.5

Open in new window

This page says that if I type import pygame and nothing happens, when I query it, it is working,
which seems unconvincing, but I'll live with it, half way down after
>>> import pygame

here

but it gets errors when I try it in bash and pycharm

>>> import pygame
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pygame

Open in new window

Thanks
0
 
beavoidAuthor Commented:
On the other hand, I found this page that says OS X users need to install Xquartz

I get this message:

failed due to needing System Python 2.7

herehere

They all seem to conflict!
Thanks
0
 
gelonidaCommented:
Something is really strange. The command that I suggested to type in a shell window should either fail or
print out the pygame version. Normally you should see something like this:
(mypython)gelonida@pc:~$ /usr/bin/python -c "import pygame.version; print pygame.version.ver"
1.9.1release
(mypython)gelonida@pc:~$ 

Open in new window


Please try a small variation and check send the output
(mypython)gelonida@pc:~$ /usr/bin/python -c "import pygame.version; print repr(pygame.version.ver) && echo $?"
'1.9.1release'
0
(mypython)gelonida@pc:~$ 

Open in new window


Did you manage to change the python executable for pycharm?
You can try this with.
>>> import sys ; print sys.version ; print sys.executable
2.7.3 (default, Dec 18 2014, 19:10:20) 
[GCC 4.6.3]
/usr/bin/python

Open in new window


I would expect, that in your case pycharm is still executing python 3.3, that you installed pygame for python 2.7
Why you got no output at all for my above suggested example is something I do not understand at all. (should either print some version string or an error)
0
 
beavoidAuthor Commented:
If I try the .mpkg install file:

pygame-1.9.1release-python.org-...x10.3.mpkg

I get a message on the install that says :

Pygame 1.9.1 release can't be installed on this disk.
pyGame requires system python 2.7 to install.

My Python version is 2.7.5
What is system python?
Thanks
0
 
beavoidAuthor Commented:
Thanks

Before this question, I had never heard of, or read about xQuarz, so why it has come up now is disconcerting.

I will take your suggestions, however.
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.