Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

python - Cannot install pygame in Pycharm

I'm on Windows 10 on an Asus. I'm using python 3.8. I installed successfully pygame on another computer (lenovo yoga, same OS) and worked fine. Then I tried to install the same package on this computer (the Asus) using pip and worked just fine. The issue is that when I try to import pygame in PyCharm the module seems not to exits

Traceback (most recent call last):   

File "C:/Users/nicho/PycharmProjects/test/pygame_/2d pvm game/game.py", line 2, in <module>
import pygame ModuleNotFoundError: No module named 'pygame'

Importing on the python console or using the default IDLE works fine. I also tried to import the package from Pycharm both using the quick fixes and going to File > settings > Project: name of my project > Project Interpreter and i clicked the + icon to add pygame. This worked fine for all packages but pygame. When I try to install it using Pycharm I get the error

Error occurred when installing package 'pygame'. Details...

Then I get the details

Collecting pygame   Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3805c050dfaa81c8094d6441db2be/pygame-1.9.6.tar.gz
    Complete output from command python setup.py egg_info:


    WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
    Using WINDOWS configuration...


    Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x86"? [Y/n]Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:Users
ichoAppDataLocalTemppycharm-packagingpygamesetup.py", line 194, in <module>
        buildconfig.config.main(AUTO_CONFIG)
      File "C:Users
ichoAppDataLocalTemppycharm-packagingpygameuildconfigconfig.py", line 210, in main
        deps = CFG.main(**kwds)
      File "C:Users
ichoAppDataLocalTemppycharm-packagingpygameuildconfigconfig_win.py", line 576, in main
        and download_win_prebuilt.ask(**download_kwargs):
      File "C:Users
ichoAppDataLocalTemppycharm-packagingpygameuildconfigdownload_win_prebuilt.py", line 302, in ask
        reply = raw_input(
    EOFError: EOF when reading a line

    ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in C:Users
ichoAppDataLocalTemppycharm-packagingpygame

Could someone please tell me how to solve this issue?

NOTE: Every package works but pygame

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same issue, and ended up going into cmd and doing pip install pycharm , and then going by into pycharm > settings > project > project interpreter, and swapping the interpreter from the virtual to my python install location. All my already installed stuff showed up in the list, and I could install other things without a problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...