Python not finding module after installing with pip - python

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?

Related

Can`t import pygame to VScode despite having it installed

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.

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.

ImportError: No module named requests but module already exists

My code fails when it tries to import requests, despite it already being installed. I did a pip list and saw the module requested there, I uninstalled it and reinstalled it with both pip install and pip3 install, also added sudo both times. Whenever I try to install it I get the message that the requirement is already satisfied. Is there something else that I could try?
If it helps I am using VSCode on a Mac, I also have Jupyter and Spyder installed and have used them before however I’ve never used the requests module on this device.
UPDATE:
I created a virtualenv and installed requests there, when running the script in the venv I am not getting the error anymore, however I am still curious why it was being thrown on the base env, anything else I could check?
You probably have multiple installations/environments.
Before the "import requests", line put "import sys; print(sys.executable)".
This prints the python executable being used - verify that it is the same one that you can successfully import requests with .
What worked for me was deleting three folders having names starting with "request-SOMETHING" in the directory that pip3 specifies when you try to install requests again, e.g.
Requirement already satisfied: requests in /usr/lib/python3/dist-packages
Then just reinstall with pip and it should be in your sys.executable directory.
Try this
pip install chardet2 urllib3
or
python3 -m pip install requests
There is a problem with package dependency

Why do i still get ModuleNotFoundError when i try to import textract even after successfully installing the module?

I have successfully installed textract module using pip install textract on windows 10 after following these steps, but when i try to import textract(using Spyder IDE python 3.6.10 anaconda), i get ModuleNotFoundError: No module named 'textract'.
In command prompt when i enter the pip list command, i can see the mentioned module version 1.6.3, but when i enter conda list i can't find it.
I have added the paths in the system environment variables for conda, and also for pip.
I am new to python, did i miss anything? or is it that i can't import modules installed from pip and it should be installed with conda?

ModuleNotFoundError using pip

I have installed the module alpha_vantage using pip. In CMD writing import alpha_vantage does not show an error message, so I assume it is installed properly.
However, when trying to import alpha_vantage in a python program I get this error: "ModuleNotFoundError: No module named 'requests'". I assume the issue is due to the location of the module.
The project is located here:
C:\Users\M\Documents\Python\Investering.
I tried placing the module here by pip: C:\Users\M\Documents\Python\Investering\modules\alpha_vantage
Note pip did not install the module there I simply copied the module folder and placed them in the project folder.
Is it possible to simply copy and paste module folders in other projects? Or how am I supposed to make python acknowledge the module?
The module was installed here:
C:\Users\M\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\alpha_vantage
I'm quite new to python. I have tried adding to sys.path the folder where the module was installed, but it did not seem to help.
Thanks for any help.
Edit: I tried pip install requests and it produced this:
Requirement already satisfied: requests in c:\users\martin\appdata\local\programs\python\python38-32\lib\site-packages
Someone mentioned running: "pip install foo"
It, however, produces this error message:
ERROR: Could not find a version that satisfies the requirement foo (from versions: none) ERROR: No matching distribution found for foo
I am using PyCharm.
I found my error. I had installed python from the website, but had unknowningly installed the 32 bit version, and a 64 bit version. I uninstalled all my python versions and pycharm. Then I reinstalled everything. Now I could easily make the module work. Thanks for the pointers.

Categories

Resources