Can`t import pygame to VScode despite having it installed - python

I'm using pip 21.2.4 and python 3.9.7
I'm pretty sure I have pip installed since if I run pip --version in the terminal it gives me pip 21.2.4 from C:\Users\rohaan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip (python 3.9)
If I run pip install pygame in the terminal I get Requirement already satisfied: pygame in c:\users\rohaan\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (2.0.1)
Despite the requirement being satisfied when I import pygame I get ModuleNotFoundError: No module named 'pygame'
Does anybody know how to fix this?

It looks like you are not using the python interpreter which you have installed the pygame package.
You can execute this code to verify which python interpreter you are using:
import sys
print(sys.executable)
Then you can switch the python interpreter to which you have installed the packages or you need to activate the environment before you want to install the package in order to install the package to the right place.

This means you have multiple versions of python installed on your device, one has the module and the other tries to run the file, go to the control panel and check it out.

Related

Python isn't recognizing installed modules on Raspberry Pi

I've installed Pillow using the Pip command, and it says it's installed in the system. When I run my Python3 program that imports Pillow, it returns a module not found error.
Here is the error:
sudo pip3 install Pillow
This returns:
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (8.1.2)
Then after I run my Python program which uses Pillow, I get this:
ModuleNotFoundError: No module named 'pillow'
Thanks!
Maybe you are using another version of python when you run your script..
Try to run your script from the terminal and write before it (python3)
You are probably trying to run it with a different python version or in a virtual environment, you can provide controls by going into the settings of your code editor.

Python not finding module after installing with pip

I installed nba_api using pip install nba_api in the anaconda powershell prompt. It says that the requirement is already satisfied. I followed the path, and it is indeed there. However, when I try to import in spyder, it says No module named 'nba_api'
How do I fix this?

What is the reason of ModuleNotFoundError: No module named 'mysql' in Python 3.8.10 and Requirement already satisfied in anaconda location problem?

I need to import mysql-connector and I installed it by using pip install mysql-connector-python.
After the installation, I can see the same error is displayed.
After that again I tried to install mysql connector, but it displayed that Requirement already satisfied and show a path in anaconda lib folder.
Is there any effect from previous installation on Anaconda and how to import mysql-connector to code?
As a solution for that, I changed the interpreter of the code into ('base': conda). It worked correctly without any error.

Conda package cannot be installed into the PyCharm virtual environment?

The attempt to install the conda package from File-->Settings-->Python Interpreter becomes unsuccessful. The following was the output
The message from PyCharm is
ERROR: Could not find a version that satisfies the requirement menuinst (from conda) (from versions: none)
try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at '<UserName>\Pycharm\pythonProject\venv\Scripts\python.exe'.
The output of
<UserName>\PyCharm\pythonProject\venv\Scripts\python.exe -m pip --version
is pip 20.2.4. The pip version in PyCharm interpreter settings is also pip 20.2.4
When I first tried to import numpy by just typing import numpy as np , PyCharm was not successful in installing numpy and gave the message to install using pip from the terminal, installing from the terminal was not successful either. Then Numpy was installed from the Python Interpreter Settings at File-->Settings. Afterwards, before getting NumPy installed, PyCharm even became unable to detect the import statement and to offer to install NumPy
How would Scientific mode be enabled for the current project given that the conda interpreter is not installed?.
How to get the conda package(interpreter) installed from within PyCharm
What is the defect that prevented PYcharm from detecting the import statement in the editor
and giving the message "No module named numpy" with the offer to install NumPy.
What is the reason causing the pip error?

Pycharm Error - No module named MySQLdb

I have installed MySqldb as shown below:-
jab-MacBook-Pro-4:silkroute deb$ pip install MySQL-python
Collecting MySQL-python
Installing collected packages: MySQL-python
Successfully installed MySQL-python-1.2.5
But still I am getting the error:-
python --version
Python 2.7.11
I am using version 2.7.10 in PyCharm
I have also installed MySQLDB as shown below:-
jab-MacBook-Pro-4:silkroute deb$ pip2.7 install MySQL-python
Requirement already satisfied: MySQL-python in /usr/local/lib/python2.7/site-packages
Can someone let me know how can I get rid of this error?
Your Pycharm was not using the right python environment.You can change the project interpreter by setting Pycharm.
Step:File-> SettingsIn Popup menu: Project-> Project Interpreter-> add or create virtualenv environment
After changing project interpreter, the Pycharm has many function to use
Open PyCharm, File>>Default Settings>>Project Interpreter>>Select the Interpreter you want to install the packages to, press the red '+' sign to the right, search the package and install.
This should most probably correct your error. You are better off creating a virtualenv though, will be really helpful. Use this to get started
You may have multiple Python versions installed.
Use pip2.7 to see if this installs on the right python version.
Check this post: pip: dealing with multiple Python versions?

Categories

Resources