ImportError when using pip install - python

I tried installing 'pandas' and 'xlrd' using pip install but I get this error from python when I try and use the modules: ImportError: No module named xlrd. Same error when I use pandas. I have tried various methods from the internet to solve this issue including:
changing package permissions
using sudo pip install
adding PYTHONPATH export in the bash_profile file.
using pip3 because I have python 3
I even tried this approach https://stackoverflow.com/a/49602260, but in my case I already had the package location(which I got using pip show xlrd) inside the sys.path list.
None of the above approaches have worked for me.
Edit: I use VSCode as my IDE and I run my files through the inbuilt terminal.

Related

ModuleNotFoundError: No module named 'mysql' continuously occuring in VS Code despite multiple attempts to resolve

I seem to be facing this error continuously despite:
Installing the mysql-connector via "python -m pip install mysql-connector-python"
Installing the MySQL package via "pip install MySQL"
I have confirmed that I have installed the package as it says "Requirement already satisfied everytime I run it again in the terminal". Additionally, I have tried installing and reinstalling the package as well.
But all the results are the same. Each time I run my script and try to "import mysql.connector", I always get the ModuleNotFoundError: No module named 'mysql' error
Would greatly appreciate some help. Thank you very much
Do you use virtual environments? If it is a virtual environment, please copy the contents in the expansion package folder of the virtual environment to the package folder under python.
If you have two versions of Python in your system, you may also encounter this problem. "CTRL+SHIFT+P" and choose the correct interpreter.
You can use the following method to check and see where pip installed the package:
pip show MySQL

no module named <library_name>

I am having error importing modules in my jupyter notebook when running it on a mac machine after successfully installing them using:
!pip install <library name>.
I try it on several modules and error persists.
for example, when running this code
!pip install pyenchant
I get this:
Requirement already satisfied: pyenchant in
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
(3.2.2)
when running :
import enchant
I am getting an error message:
ModuleNotFoundError: No module named 'pyspellchecker'
then try to run this (as I read this could help)
!python -m pip install -U pyenchant
and get that:
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named pip
I think it has something to do with python path and bash_profile but I do not have an intuition for it.
I do not know if it is helpful/relevant, but I have Pycharm, python, Visual Studio Code and anconda installed on my machine. I am doubting that the problem comes from misalignment between the common configuration files of these programs.
can you please help?
I realize that many has encounter similar issue but their solutions did not help me.
p.s. the issue disappear when I use conda install , but I would like to use pip as it give me access to larger library options.

Can't access Pandas

Hi I am having major trouble with shell.
I am not able to change the path for pip and python.
Python 3.7 is downloaded elsewhere.
Pip has an unknown path. I tried upgrading pip but it stored a blob of code and I don't know what to do with it.
Pandas not available on terminal (shell) which uses python 2.7.
Errors:
ImportError: No module named pandas
After pip install pandas I get the message: Successfully installed numpy-1.19.1 pandas-1.0.5 pytz-2020.1
I still get the message No module named pandas
please help. I have been really frustrated by this!
Have you tried pip3 install yet?
pip could default to the installation of pip for python2 as well.
Finally, if it is doable in your system, you may uninstall python 2 completely as it is out of support anyway, this would save you a lot of headache in the future!
Try
pip3 install pandas
and if that doesn't work, then try
pip install pandas
EDIT:
It sounds like you should try to run your code using python myfile.py instead of python3 myfile.py

Python, 'no module named {package}' error

I'm trying to use a package I installed using pip and it got installed in C:\Program Files\Python\Python38\Lib\site-packages, but when I import it in my IDE I get an error saying No module named instabot. I have had this error before and I'm unsure of what is happening
The problem might be that you are using a virtual environment in your IDE. If you using PyCharm, consider taking a look at this link.
Try pip or pip3 installing it in the right environment depending on your python version.

I have installed the package from github but when importing module name not found

I'm trying to use this github repo!
but as soon as I import the package: from pykernels.basic import RBF
the following error is displayed:
ModuleNotFoundError: No module named 'basic'
I have double checked everything given my understanding of python, packages and how anaconda works but I don't know very much. The site-packages are in the path, the evn has the package and the init seems to be alright. I am really lost, if someone could tell me what I'm doing wrong or what else might be done to resolve this? Thank you!
for installation:
pip install git+https://github.com/gmum/pykernels#egg=pykernels
If you have installed both anaconda and original python, you will have two pip installed in your computer. The original python will have it's pip in \Python37\Scripts, and anaconda will have it's in \Users\admin\Anaconda3\Scripts. Your problem is that you used pip that is in \Python37\Scripts, the original pip. The original pip will install into the original python site-packages, not Anaconda's site-packages.
The solution is to make sure you're using Anaconda's pip when installing packages for use with Anaconda.

Categories