简体   繁体   中英

Why does python give me a import error for pygame.base?

When trying to import pygame I get the following error:

File "C:\Users\Jesse\.spyder-py3\Aliens\pygame\__init__.py", line 120, in <module>
from pygame.base import *

ImportError: DLL load failed: The specified module could not be found.

I don't know why it cannot find pygame.base. When I installed pygame I took the folder and pasted it right in the same directory my python program is running in. There is a base.pyd file in the pygame folder, so why is it giving me an import error?

Not sure if this is related: I installed pygame using pygame-1.9.6-cp36-cp36m-win_amd64.whl . After doing some digging in my computer, it seems like I have two versions of python installed (3.6.5 and 3.7.3).

I think you should paste the pygame folder in the folder where you have all your standard modules (eg os, sys, math etc.), not in your folder where you have your program. For example, I am using MacBook, and my standard library is in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6 .

You can find your standard module library by finding the directory of your pre-installed standard module and then paste your pygame folder in that directory. For example, you have ctypes installed on your python. So you can enter the following code in your python shell:

import ctypes
print(ctypes.__file__)

The output will be the full path to the file. You can paste pygame into the same directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM