Pygame Window Not Displaying in PyCharm, but Displays Normally through Terminal

Answered

Hi,

I'm running a MacBook Pro 13in 2017, Mojave v10.14.6. I'm using latest Pycharm and installed PyGame (v1.9.6) through it.

When I run a simple Pygame script through pycharm a pygame window appears, but with nothing displayed. However, when I run the same scrip through the terminal the shape appears correctly. I've attached a photo of what I'm describing.

Let me know if I can provide more details.

Thanks!

4 comments
Comment actions Permalink

Hello, 

 

Could you please upload the code you are executing in a file to the FTP: https://uploads.services.jetbrains.com/

 

Let me know the folder name,  and I will be able to reproduce the issue in my lab.

 

 

 

0
Comment actions Permalink

Hi Antonina,

Thanks for responding. I uploaded it as "main_pygame_test_1.py" using the upload service you linked to.

Since posting, I've read that my issue could be caused by running pygame in a "virtual environment" within Pycharm. I'm not really sure what that means, but maybe it helps since running pygame through my Mac's terminal works fine with the same code.

0
Comment actions Permalink

Hello Sielerjm, 

Yes, the assumption about the "virtual environment "   is correct.  The thing is that you are running the same script in different environments:  in PyCharm it is a virtual environment configured for the project,  in terminal it is anaconda environment (to know for sure, run  > which python ).  

If you activated the virtual environment in the terminal and run the code, it would not display any picture. So, it confirms the issue is out of PyCharm scope. For some reason, the output cannot be displayed in the virtual environment. 

However, as a workaround, you can create a Conda environment in PyCharm  https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.html  and use it instead of the current one. 

Please let me know if there are any questions. 

 

0
Comment actions Permalink

Hi Antonina,

Using the Conda environment worked! Thank you so much for your help!

As a side note, in case others look this up. I had to also reinstall pygame (pip install pygame) within the terminal of Pycharm within the Conda environment.

Cheers,
Michael

0

Please sign in to leave a comment.