error in import pandas after installing it using pip - python

I installed pandas using pip and get the following message "pip install pandas
Requirement already satisfied (use --upgrade to upgrade): pandas in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Cleaning up..."
When I load up python and try to import pandas, it says module not found. Please help

Try to locate your pandas lib in /python*/lib/site-packages, add dir to your sys.path file.

Following the previous answer try this after opening a python shell:
import sys
new_path = "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages" # or wherever your pip install drops things
sys.path.append(new_path)
import pandas

Related

Python Deprecation warning

DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working.
These are my import statements.
import pandas as pd
import numpy as np
import os
import pymssql
os.getcwd
os.chdir('D:\Sushil\Output')
How can we fix this, since I am running spyder IDE for development connecting to sql server.
Looks like you are using older versions of python packages. Please update these packages using the following commands in cmd.
pip install --upgrade pymssql
pip install --upgrade pandas
pip install --upgrade numpy
Yes the warning message was regards pymssql. I have upgraded to the newer version. It is working. No more warning message now.

Trouble importing Tabulate with Python 3.7

I'm running Python 3.7 on Windows 10 and I keep getting No module named 'tabulate' error. I have deleted Python 2.
I've tried everything suggested in a similar question:
>> pip install tabulate
>> pip3 install tabulate
>> python -m pip install tabulate
All of the above respond with
>> Successfully installed tabulate-0.8.6
If I try to run it again, I get
>> Requirement already satisfied: tabulate in c:\program files\python37\lib\site-packages (0.8.6)
But I keep getting the same ModuleNotFoundError when I try to import it. What can I try still?
UPD:
I have double-checked whether old versions of Python were uninstalled, and to my surprise EVERYTHING was still there: the folders, the files, the paths in the PATH... I'm afraid that was the reason of my problems, but I won't be able to test it until later.
I solved this issue by updating tabulate to the latest version using:
pip install --upgrade tabulate

No module named 'numpy' but Requirement already satisfied: numpy

When I want to execute my script I got the error: ModuleNotFoundError: No module named 'numpy'. But the module is already installed as said me the answer to the install command:
C:\WINDOWS\system32>pip install numpy
Requirement already satisfied: numpy in c:\users\simeo\anaconda3\envs\tensorflow1\lib\site-packages (1.17.2)
I'm quite new with Python, so I don't understand why it's not working and what could be the problem.
I'm using Windows 10 (64 bits). I installed Python 3.7
Thanks in advance!
For Windows try either two of these methods in cmd:
pip3 install numpy
pip3 install -U numpy
directly download latest version from sourceforge.net
If you are using pycharm, it can not install numpy from interpreter settings. After one of above method works, try installing numpy in pycharm again through interpreter settings.
You need to upgrade your Numpy library. Your current Keras version is not compatible with your Numpy module. You can use the below-given command to upgrade Numpy.pip install -U numpy
Try adding this to your code, above everything else:
import numpy

No module named openpyxl - Python 3.6 - OSX

I've installed openpyxl from the Terminal using
pip3 install openpyxl
without any problems. I've even double-checked by simply running import openpyxl from the Terminal window once Python is running, and it imports no problem.
The problem starts when I try and import openpyxl from a script I'm building to work with a spreadsheet. I'm using Sublime Text and can't even get past the import openpyxl at the beginning of the script without running into the following error:
Traceback (most recent call last):
File "/Users/wcw/Desktop/test.py", line 1, in
import openpyxl
ImportError: No module named openpyxl
How can this be happening? I know I've installed openpyxl correctly from the Terminal window without any errors so how can my script not find the module?
Try to do:
pip3 install --user openpyxl
Doing the --user worked for me when I tried to run my .py files with matplot lib modules which worked in 3.5 but not in 3.6.
I have the same problem.
I've installed the openpyxl succesfully via Anaconda
!pip3 install --upgrade openpyxl
Collecting openpyxl Using cached
https://files.pythonhosted.org/packages/95/8c/83563c60489954e5b80f9e2596b93a68e1ac4e4a730deb1aae632066d704/openpyxl-3.0.3.tar.gz
Requirement already satisfied, skipping upgrade: jdcal in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.4.1) Requirement already satisfied, skipping upgrade:
et_xmlfile in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.0.1) Installing collected packages: openpyxl Found
existing installation: openpyxl 1.8.6
Uninstalling openpyxl-1.8.6:
Successfully uninstalled openpyxl-1.8.6 Running setup.py install for openpyxl ... done Successfully installed openpyxl-3.0.3
But when I try to use tat library I get an error No module named openpyxl
import openpyxl
ModuleNotFoundError: No module named 'openpyxl'
If I try to import openpyxl in Terminal, I don't have the error. What's wrong?
This may be overly simplistic, but I had the same problem. I installed the module successfully but import openpyxl resulted in an error. I needed to close IDLE and start a new session. After that, my import command worked just fine.

Python packages not available after install with pip

I am working on a Macbook with Python 2.7.5 pre-installed. I installed the pandas package via command-line with the following code.
pip install pandas
This completed without errors. However, when I try to run the following code in Netbeans, I get an error.
if __name__ == "__main__":
import pandas as pd
The error is: ImportError: No module named pandas
When I try to re-install the pandas package in the terminal I get the message: Requirement already satisfied (use --upgrade to upgrade): pandas in /usr/local/lib/python2.7/site-packages
What am I doing wrong here?
Thanks for the help!

Categories