I am trying to learn Python by following the book "Python Crash Course", but I'm stuck because the book does not use the IDE I am using, PyCharm.
The problem I encounter is when I try to import pygame it says module not found
.
I successfully installed pygame using this command:
python -m pip install --user pygame
I get the message "successfully installed pygame"
but I'm still unable to import it. I noticed that PyCharm uses the interpreter from this location: \\HelloWorld\\venv\\Scripts\\python.exe
which is inside the project folder.
My python is installed in:
\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe
How can I give PyCharm's virtual environment access to pygame?
Thanks!
尝试从 pycharm 中给出的项目解释器安装包
PyCharm -> Prefrences -> Project -> Project Interpreter -> Add Local
Thanks for all your suggestions, Both jackotonye and om tripathi's answer are correct I just prefer jackotonye's but instead of 'add local' I install pygame module
Here's what I did, on PyCharm to go:
File -> Settings -> Project: HelloWorld -> Project Interpreter -> '+' (plus sign)
this will allow you to install packages/module in your venv.
but I think you will have to do this for every project you will create unless you selected "Default Settings" instead of "Settings" on the above instruction I stated.
PS: om tripathi's answer works as well, changing the interpreter to my native python instead of the venv's python.
Thanks!
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.