I'll preface by saying I'm a programming n00b by stack standards. I have experience with data analysis and scripting -- this is what I do professionally at a financial firm -- but I have no idea what I'm doing on the back end.
I'm trying to start using pandas and python --- moving away from matlab/vba but I can't figure out how to install the pandas library.
When I try to import pandas I get an error that numpy module is not present. I tried to install ezsetup / pip (no idea what this is btw)... and I have no idea where to enter this command$ python get-pip.py
Sometimes when I try to import pandas I get an error cannot import name table hashable
I have no idea what any of this means and I am not getting anywhere.
Update
Ok I installed anaconda and it seems to be allowing me to import numpy and pandas directly from the console. That being said when I try to write a basic time series and plot it using pandas syntax, i get an error that "series is not defined" as such I'm not sure if it is actually working
In [1]: import matplotlib.pyplot as plt
In [2]: ts = Series(randn(1000), index=date_range('1/1/2000', periods=1000))
In [3]: ts = ts.cumsum()
In [4]: ts.plot()
The best resource for third-party modules for Windows is Christoph Gohlke's Python Extension Packages for Windows repository. Each module is available as a self-extracting .exe installer, for use with the python.org version of Python - make sure you get the correct installer for your version and architecture.
While NumPy does not require any other packages, pandas does, so make sure you get them all. The installation order is not important.
The advantages of this resource over a distribution like Anaconda or Enthought is that Dr. Gohlke keeps the packages very up to date, allowing you to run the latest versions of the modules. Additionally, nearly all of the modules have multiple Python versions, while some of the other distributions are only based on Python 2.7.
The disadvantage is that you need to install each package individually, and there is no package manager for handling dependencies.
Best to use a pre-packaged solution, Anaconda or Enthought particularly with windows
Try this: It should work.
Go to the location where you have Python (C:\Python34)
Run the blow command:
python -m pip install pandas
NUMPY installed automatically after my Pandas installation.
I had the same headaches and the solution I finally found was to install python xy. This seems to include every package I have ever dreamed of using, and weeks of frustration evaporated almost instantly (related to pandas and many others. It's a great collection of everything you will need. It includes most all of the libraries mentioned above)
While YMMV, Enthought's Canopy caused issue after issue after issue for my installation. I advise to steer clear.
First upgrade pip version using command python -m pip install --upgrade pip after that just do pip install pandas
Note : - For pandas python-dateutil, numpy, setuptools and pytz module required.
To install pandas for Python 3, you may need to use the python-pandas package.
While NumPy does not require any other packages, pandas does, so make sure you get them all. The installation order is not important. ... The disadvantage is that you need to install each package individually, and there is no package manager for handling dependencies.
To Install numpy pip install numpy
To install pandas pip install pandas
Related
I've scoured the internet without much luck of finding how to fix what I'm doing wrong. I think I have all the pieces to the puzzle and know what is wrong but I just don't know what I need to do to fix it.
I'm starting to think I have two installs of python and I'm not updating the install that's being used in VS code and the python install that I have updated is not properly setup in VS code. I have anaconda downloaded but I think the VS code python extension is the only one that is set up properly. If I use the anaconda prompt and follow what a number of posts/solutions detail
import pandas as pd
pd.__version__
I get 1.1.3 which I believe I updated the other day when trying to fix my issue. However, if I use the terminal in VS code and do the same thing, I get 1.0.5 (which is the pandas version that produces the issue I am dealing with... it messes with dates when plotting pandas df). I'm guessing this has something do to with anaconda not being set to PATH and VS code is using the extension instead of the anaconda download. To further back this up, if I select
Python 3.7.9 64-bit (conda) interpreter instead of Python 3.7.9 64-bit
and run code that typically works on the non-conda interpreter, I get the following:
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "C:\Users\user
\anaconda3\python.exe"
* The NumPy version is: "1.19.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: The specified module could not be found.
If what I suspect is the issue, then I'm a bit confused how I've been able to import and use packages such as pandas, matplotlib, and Numpy when using the non-conda interpreter.
Would someone be able to explain and steer me in the right direction?
The reason for getting two different versions of "pandas" is that the Python interpreter you are using is different. The "Python 3.7.9 64-bit" you use is the python interpreter (global environment) that you downloaded and installed, and the "Python 3.7.9 64-bit (conda)" is the Python interpreter that comes with Anaconda (conda environment).
According to the terminal information you provided, there is no dependent package "numpy" of "pandas" in a non-conda environment. It is recommended that you install the module "numpy" (pip install numpy). Usually, when the module "pandas" is installed, the terminal will automatically install the dependencies it needs. Therefore, you could also reinstall "pandas" in the VSCode global environment.
If you want to specify a certain version of the module "pandas", you could use "pip install pandas==1.1.3" to install version 1.1.3.
After having try many times and after searching a lot, I still don't manage to use opencv-python. Actually, import cv2 works for me, but when I want to make this file working, I got this message
Importing the multiarray numpy extension module failed
Do you have an idea of what is going on ?
In Python, OpenCV images are using the same data representation as Numpy arrays. It's quite frequent to use numpy logic on OpenCV images and vice versa.
So first thing to check is that you have numpy installed.
Assuming you have numpy installed, maybe you mixed pip and conda commands to install opencv and numpy ? It's generally something to avoid unless you really know what you are doing.
You can run pip list and conda list to have a quick overview of installed packages.
Using pip only is good enough in most cases, a lot of prebuild python wheels for Windows are available on pip, including opencv-python and numpy.
After cleaning conda installed packages, try to run :
pip install --upgrade --force-reinstall numpy to make a clean numpy install.
I am new to python and I am trying to make a simple stock market program using pandas to import the data. I have installed Anaconda which said that it installed pandas along with it, as well as Python 2.7. I use PyCharm as my IDE. When I run:
import pandas as pd
from pandas_datareader import data
I receive the error message
import pandas as pd
ImportError: No module named pandas
I am not sure why it is giving me this error message so any help would be greatly appreciated
When entering the command to run your file, make sure you specify which version of python you're using. For example, instead of python filename.py, use python3 filename.py or python2 filename.py
Try to install it using sudo ...
sudo pip3 install pandas
for ubuntu ... it worked got me. pip or pip3 .. as per your requirement.
You need to pip install pandas and things will work.
Your issue is that pandas is not installed locally on your computer. Luckily, this is a simple task to accomplish by opening up either a Terminal or Command Prompt (depending on your OS), and typing in the command pip install pandas. This will install pandas and you will be good to go!
The issue is that Anaconda installs a Python version of its own, and likely the Python version is Python 3. When you use PyCharm IDE as your editor, you are using another version of Python (Python2). For my Mac, Anaconda's Python is installed under /anaconda3/bin and my default Python is installed under /usr/bin/python.
I recommend you either config PyCharm to use Anaconda's Python, or use Anaconda's Jupyter your project. Jupyter is arguably a stronger tool considering that you are doing data analytics task.
Also, for Anaconda's python, you shoud use conda install pandas instead of pip install pandas to install additional packages. This is not necessary this time since it's already installed.
I have a question which is very similar to Import Error: No module named numpy but the answer to that question I do not believe would be appropriate for me, so I'm asking again.
This is my most recent effort after about six hours of trying to get modules to work in python (numpy is a dependency of something else), so I'm finally turning to SO. Part of efforts in the last six hours included installing the enthought distribution, as its large volume of libraries was highly advised for windows users. I've even thrown the location of numpy folder onto the path of environment variables just to exclude it as a possibility.
Windows, 64bit, Python 2.7
Since you are on windows, I highly recommend that you install ANACONDA. This way the environment variables are set automatically and you don't need to worry about anything else. There are many useful packages (e.g. numpy, sympy, scipy) which are bundled with anaconda.
Moreover, based on personal experience I can tell you that using pip on windows and compiling from source (you need visual studio) is a pain in the neck sometimes. That's why ANACONDA has been conceived.
Hope this helps.
For python versions > 3.4 ,do this
pip install numpy beacuse pip is python dependency which installs packages just like npm in js i.e. node.js
Hi I'm trying to install matplotlib on my mac. I have lion OS X.
my python version is 2.7.1 ( this is what it says when I run it from terminal)
every time I install matplotlib, it promots this error
matplotlib 1.1.0 cannot be installed on this disk. matplotlib requires System python 2.7 to install.
I'm new to the python world and I need a tool to graph a few things... so a clear explanation is much appreciated.
Thanks!
You are installing a binary package which is going to expect a specific system python. You are better off building from source.
Just try installing it from pip:
pip install numpy
pip install matplotlib
If you do not yet have pip, you can install it like this:
wget "http://peak.telecommunity.com/dist/ez_setup.py"
python ez_setup.py
easy_install pip
If any of this fails, then follow #Nolen Royalty's guide that he mentioned in the comments
I've tried installing python in various different ways to get numpy, scipy, and matplotlib to all work together, and its a huge pain. Your exact version of python will dictate the version of numpy, scipy, and matlplotlib that will work for you.
By far, the easiest solution I have found is to use the pre-built package Enthought. It takes care of all of those problems with one easy installer. You might get some additional software installed like mayavi (an interactive 3d plotting tool), but its not too much.
If you are a student (or have ever been one since the dawn of email), you can download the entire Enthought package for free here. Or you can visit the Enthought home at www.enthought.com. All you have to do is select the academic license and then insert a email that ends in .edu.
I even think there are free trial versions which should solve the issue. I've never tried any of the trial versions, but even if it is a limited time trial, you should be able to use the trial version, and then see exactly which versions of each package you need to install. Its a little more roundabout, but it should work.
I tried to install numpy, scipy, and matplolib on my Mac Book Pro running Lion many times and they all failed. Nolen's recipe cam pretty close, but some of the matplotlib tests were failing in strange ways. The method that worked for me can be found on the page Installing Python, virtualenv, NumPy, SciPy, matplotlib and IPython on Lion
Since you list you are new to Python, I recommend installing matplotlib with MacPorts. First install macports
http://www.macports.org/install.php
then execute
port install py27-matplotlib
A couple of years ago there were some extra steps, but now it is this simple. You need to make sure you set your environment for the macports python, but that is provided in the documentation.
Have Fun!