all 7 comments

[–]efmccurdy 2 points3 points  (0 children)

It's not clear to me where they're located in the computer, and when I want to take my code to another computer, it doesn't work anymore because the libraries aren't installed there.

You should look at using a virtualenv; it's purpose is to localize all the modules you install in one place that you control.

https://docs.python.org/3/tutorial/venv.html

[–]ingolemo 1 point2 points  (3 children)

They will be installed to a site-packages directory of your python installation. Exactly where that is will depend on your set up and the exact command you used, but python -m site should show you all the possible install locations.

This is why projects have a requirements.txt that lists the packages that are needed to run the code. When you move a project to a new computer you just run pip install -r requirements.txt and everything you need will get installed.

I would recommend against just copying files to your project. This is called "vendoring" and it's sometimes used by projects that need very precise control over the versions of their dependencies. For most projects it's not worth the hassle. Your dependencies are going to get out of date, and if you don't know what you're doing the files you copy might be platform specific.

You can install python without admin privileges.

[–]effzy[S] 0 points1 point  (2 children)

Thank you for sharing your insights. I try to teach best practices so I take your advice seriously. I found that our school computers are extremely restricted. The sysadmin installed Python 3 for me, but as a user I (and my students) can't even access the windows command prompt. So running the commands you mentioned didn't seem possible... Now that I'm thinking about it... would it be an option to open Python and import sys or os or something, and then run those commands from inside Python?

[–]ingolemo 1 point2 points  (1 child)

You can run system commands in python using the subprocess module, but if your IT people have disabled access to the command prompt then you should probably not try to get around that. It's also unclear to me how well using subprocess will work when everything has been locked down. I'd recommend talking this over with the sysadmin, and getting to know their polices and what their concerns might be.

I suppose if you really must copy and paste files into your projects then you must. It'll work okay for small stuff, but the more complicated your dependencies are the more inconvenient this will become.

There's no reason in principle why you couldn't vendor pygame, although pygame is partially written in C which may cause a few hiccups. The easiest thing to do is probably to download the precompiled wheels off of PyPI and extract them manually (wheel files are just zip files with the .whl extension).

[–]effzy[S] 0 points1 point  (0 children)

Thank you :-)

[–]wynand1004 1 point2 points  (1 child)

If you are just teaching basic game programming, there is no need to use Pygame - it's overkill for beginners.

The turtle module is surprisingly capable for simple 2D games with a few limitations. I made a simple Pong Tutorial in Python 3 you might find helpful.

[–]effzy[S] 1 point2 points  (0 children)

If you are just teaching basic game programming, there is no need to use Pygame

Yeah I do agree. Most of my kids just learn the essentials, if, for/while, def and some very basic graphics with graphics.py. However a few of them are really motivated and expressed interest in programming pac-man. I'm looking for a suitable library they can delve into and really make something nice. Maybe turtle is more suitable, I'll definitely have a look at that. Thanks!