![]() |
How do I get pygame module to work in Spyder? (Mac) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How do I get pygame module to work in Spyder? (Mac) (/thread-38988.html) Pages:
1
2
|
RE: How do I get pygame module to work in Spyder? (Mac) - FirstBornAlbratross - Dec-17-2022 (Dec-16-2022, 11:53 PM)snippsat Wrote: Use command line(Terminal) and use command that show. pygame 2.1.2 is already installed (via terminal). pygame in "./.local/lib/python3.9/site-packages (2.1.2)" Edit: I'm trying your solution (properly this time). Edit2: I can't find the "python3.9" path for my interpreter. RE: How do I get pygame module to work in Spyder? (Mac) - snippsat - Dec-17-2022 Then your path in Spyder should be ./.local/lib/python3.9/python Or it can use /usr/local/lib/python3.9/python ,test with which python or python -c "import sys; print(sys.executable)" to get the correct path.It will install to ~/.local if you don't have admin right to modify the system-wide /usr/local .Can use ls -a from command line to see dot directories.A file explore should show the dot directories. What is ~/.local folder in Mac OS used for? RE: How do I get pygame module to work in Spyder? (Mac) - FirstBornAlbratross - Dec-17-2022 OK so after using "which python" and "python -c "import sys; print(sys.executable)"" the path is shown as: /opt/miniconda3/bin/python My current interpreter is set to the above but alas I get a new error message now: Traceback (most recent call last): File "/opt/miniconda3/lib/python3.9/site‑packages/spyder_kernels/console/__main__.py", line 24, in start.main() File "/opt/miniconda3/lib/python3.9/site‑packages/spyder_kernels/console/start.py", line 328, in main kernel.initialize() File "/opt/miniconda3/lib/python3.9/site‑packages/traitlets/config/application.py", line 113, in inner return method(app, *args, **kwargs) File "/opt/miniconda3/lib/python3.9/site‑packages/ipykernel/kernelapp.py", line 669, in initialize self.write_connection_file() File "/opt/miniconda3/lib/python3.9/site‑packages/ipykernel/kernelapp.py", line 256, in write_connection_file write_connection_file( File "/opt/miniconda3/lib/python3.9/site‑packages/jupyter_client/connect.py", line 164, in write_connection_file with secure_write(fname) as f: File "/opt/miniconda3/lib/python3.9/contextlib.py", line 119, in __enter__ return next(self.gen) File "/opt/miniconda3/lib/python3.9/site‑packages/jupyter_core/paths.py", line 898, in secure_write with os.fdopen(os.open(fname, open_flag, 0o0600), mode, encoding=encoding) as f: PermissionError: [Errno 13] Permission denied: '/Users/Tony' Traceback (most recent call last): File "/opt/miniconda3/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/opt/miniconda3/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/opt/miniconda3/lib/python3.9/site‑packages/spyder_kernels/console/__main__.py", line 24, in start.main() File "/opt/miniconda3/lib/python3.9/site‑packages/spyder_kernels/console/start.py", line 328, in main kernel.initialize() File "/opt/miniconda3/lib/python3.9/site‑packages/traitlets/config/application.py", line 113, in inner return method(app, *args, **kwargs) File "/opt/miniconda3/lib/python3.9/site‑packages/ipykernel/kernelapp.py", line 669, in initialize self.write_connection_file() File "/opt/miniconda3/lib/python3.9/site‑packages/ipykernel/kernelapp.py", line 256, in write_connection_file write_connection_file( File "/opt/miniconda3/lib/python3.9/site‑packages/jupyter_client/connect.py", line 164, in write_connection_file with secure_write(fname) as f: File "/opt/miniconda3/lib/python3.9/contextlib.py", line 119, in __enter__ return next(self.gen) File "/opt/miniconda3/lib/python3.9/site‑packages/jupyter_core/paths.py", line 898, in secure_write with os.fdopen(os.open(fname, open_flag, 0o0600), mode, encoding=encoding) as f: PermissionError: [Errno 13] Permission denied: '/Users/Tony' I'm not sure how to fix this since my current account is admin. Thanks for helping me out so far snippsat. I really appreciate it. It's been 2 days since I first stumbled across the pygame issue. Hoping I can resolve it over the weekend and continue learning code afterwards. RE: How do I get pygame module to work in Spyder? (Mac) - snippsat - Dec-17-2022 (Dec-17-2022, 03:46 AM)FirstBornAlbratross Wrote: OK so after using "which python" and "python -c "import sys; print(sys.executable)"" the path is shown as:Now is path set to Miniconda which is fine,but you most know how to use it. Most activate a environment eg conda activate base if you not have make one.Most have (base) environment activated,then it will use pip or conda that belong to Miniconda.Or make new environment as you see in link under How to Manage Conda Environments on an Apple Silicon M1 Mac Example is i use (base) environment.# See that now do pip point to miniconda3 (base) G:\div_code λ pip -V pip 21.3.1 from G:\miniconda3\lib\site-packages\pip (python 3.9) (base) G:\div_code λ conda -V conda 4.11.0 # Python point to miniconda3 (base) G:\div_code λ python -c "import sys; print(sys.executable)" G:\miniconda3\python.exe # Will install to this environment (base) G:\div_code λ pip install pygame Collecting pygame Downloading pygame-2.1.2-cp39-cp39-win_amd64.whl (8.4 MB) |████████████████████████████████| 8.4 MB 3.3 MB/s Installing collected packages: pygame Successfully installed pygame-2.1.2 # Start Spyder when enviroment is active (base) G:\div_code λ spyderIf you activate the conda environments then usually all will work,but if not activated it will use pip that now is set to a OS python version.You have installed Python and miniconda versions,but not all get mess together if not activate environment .
RE: How do I get pygame module to work in Spyder? (Mac) - FirstBornAlbratross - Dec-17-2022 (Dec-17-2022, 11:30 AM)snippsat Wrote:(Dec-17-2022, 03:46 AM)FirstBornAlbratross Wrote: OK so after using "which python" and "python -c "import sys; print(sys.executable)"" the path is shown as:Now is path set to Miniconda which is fine,but you most know how to use it. OK, I created a new conda environment called 'myenv' and I have successfully activated it. I still get the previous "permission" error message though. RE: How do I get pygame module to work in Spyder? (Mac) - snippsat - Dec-17-2022 (Dec-17-2022, 06:34 PM)FirstBornAlbratross Wrote: PermissionError: [Errno 13] Permission denied: '/Users/Tony'Permission denied in Mac Terminal? Python PermissionError: [errno 13] permission denied Solution RE: How do I get pygame module to work in Spyder? (Mac) - FirstBornAlbratross - Dec-17-2022 (Dec-17-2022, 08:08 PM)snippsat Wrote:(Dec-17-2022, 06:34 PM)FirstBornAlbratross Wrote: PermissionError: [Errno 13] Permission denied: '/Users/Tony'Permission denied in Mac Terminal? This was one of the lines after following the instructions: drwxr-xr-x 5 root admin 160 9 Nov 21:39 .. Not sure what to do next as I had trouble following the instructions. (instructions didn't work for me) I'm also on a Mac if that makes a difference. RE: How do I get pygame module to work in Spyder? (Mac) - snippsat - Dec-18-2022 (Dec-17-2022, 06:34 PM)FirstBornAlbratross Wrote: OK, I created a new conda environment called 'myenv' and I have successfully activated it.How are working with this environment,you most install Spyder and Pygame to this to myenv .You can not use Spyder that you installed before the can get same problems. If do this so should the environment bye in user space and should not get permission error.. If still get permission denied on /Users/Tony do this.sudo chmod -R 755 /Users/Tony Here from start i make a new my_env and install Spyder and Python 3.10.8 and test that it work.So this line will install Python 3.10.8 / pip | Spyder and conda.conda create --name my_env conda spyder python=3.10.8Now activate environment and install Pygame,see that this is active bye that is show. (my_env) (my_env) G:\div_code λ pip install pygame Collecting pygame Using cached pygame-2.1.2-cp310-cp310-win_amd64.whl (8.4 MB) Installing collected packages: pygame Successfully installed pygame-2.1.2Now start Spyder when environment is activated. (my_env) G:\div_code λ spyderSee in image that in point to this environment if not change as descripted before. So this is all stand alone and what i have install before dos not matter at all,her get new Spyder version and Pygame .![]() RE: How do I get pygame module to work in Spyder? (Mac) - FirstBornAlbratross - Dec-18-2022 This pygame module has been a total nightmare for me to solve. I spoke to one of my friends about it and he says I can learn Python without it so that's what I'm going to do. There's no guarantee that this issue will be resolved in a timely manner and I feel like I'm wasting my time with it all as it's been 3 days since this issue popped up so I'm just going to move on. Thanks again for all the help. Edit: Also for the record, the "chmod" code doesn't work for me. No such file or directory. |