Can not install pandas on windows 64 bit - python

Trying to install pandas on a new windows 64 system. I did so using:
pip install pandas
the installtion aborts with error when trying to install pytz (from pandas):
Could not find a version that satisfies the requirement pytz (from pandas)
Trying to import pandas falis with error:
Cannot import name hashtable
How can I over come it? Or should I just install the 32 bit version of pandas?

I used to have a lot of installation issues when I tried to manually create my own Python environment. I run Windows 7 64-bit and would suggest you download and try to install any one of these:
https://store.continuum.io/cshop/anaconda/
https://code.google.com/p/pythonxy/

If you're running CPython you can try to install it using the windows binaries available here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pandas
You can find several binaries, for different Python version and x64/win32. It also has a link to it's dependencies (like pytz) if you don't have them all.
My complete windows Python environment was built based on that.

Related

Getting : No module named 'clr' after changing python version

I had python 3.7.7 32bit installed on my laptop. I installed pip and pythonnet.
I have this line of code in my python project which is executing fine.
import sys, os, clr, time
from pathlib import Path
Now I have installed python 3.7.7 64bit version on my laptop. Before running the application, I changed the current python environment to point to 64bit. Upon changing the env, I'm getting the error :
No module named 'clr'
Do I have install pythonnet again for 64bit. If yes, how to do it again? Because when I try to install again it says
Requirement already satisfied: pythonnet in
c:\users\XXXXXX\appdata\local\programs\python\python37-32\lib\site-packages
(2.5.2) Requirement already satisfied: pycparser in
c:\users\XXXXXX\appdata\local\programs\python\python37-32\lib\site-packages
(from pythonnet) (2.21)
It is referring to python37-32 still. How do I target it to python37 (64bit).
I have stumbled into this issue a lot with my classmates in programming classes. The problem is that different programs point to different versions of Python. Assuming you're using VS Code, you are able to change which Python version to use, by the "Python: Select Interpreter" command.
Assuming you're using the terminal, you can change which Python version to use when you type "python", by changing your PATH environments.

How to pip install pickle under Python 3.9 in Windows?

I need the pickle package installed under my Python 3.9 under Windows 10.
What I tried
When trying with pip install pickle I was getting:
ERROR: Could not find a version that satisfies the requirement pickle
(from versions: none) ERROR: No matching distribution found for pickle
Then I tried the solution suggested in this question using pip install pickle5 but got the following error:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
I then tried to install the Tool suggested by the error but got same error message after trying again pip install pickle5.
Question
Which is the correct way to install pickle package under Python 3.9 in Windows 10?
UPDATE
There is no need to install pickle module as it comes already installed along with Python 3.x. Just needed to do import pickle and voila!
Cedric UPDATED answer is right. Pickle exists within Python 3.9. You don't need pip install pickle. Just use it.
import pickle
I found a way that I'm not sure it's the optimal but it works.
I did pip install pickle4
And then in the script just
import pickle4 as pickle
UPDATE
There is no need to install pickle as it's already within Python 3.9. Just needed to import pickle and voila!
For Generalized Summary, for almost all Python versions, you never need to worry for installing 'pickle' as it comes already installed with the python interpreter.
Hence, simple import works:
import pickle
In case this doesn't work, refer to Pickle Install Problems on Stack Overflow.
Another suggested way is to run: pip install pickle-mixin
For other Queries and Info, refer to Python Pickle Documentation.

Python Imports - Many Modules not Recognized

I am trying to follow a tutorial book called "Data visualization with Python and Javascript" and am running into many issues importing modules used in the book. I have made sure to do "pip install" on as many of the packages used as possible, and have successfully done it for packages such as SQLAlchemy and matplotlib.
However, when I import modules from SQLAlchemy and even dateutil that are used in the tutorial, I receive an import error, "ImportError: No module named {module}"
On the following lines of code:
from dateutil import parser
from SQLAlchemy import create_engine
This has occurred often enough with different modules that I am beginning to get concerned I can no longer actually follow the tutorial. I had to skip a whole section of how to use SQLAlchemy.
Furthermore, SQLAlchemy is properly installed:
Requirement already up-to-date: sqlalchemy in c:\users\{user}\appdata\local\continuum\miniconda3\lib\site-packages (1.2.15)
What obvious thing am I missing here that needs to happen for me to use these packages and modules?
EDIT:
python --version
Python 3.7.1
pip --version
pip 18.1 from C:\Users\{user}\AppData\Local\Continuum\miniconda3\lib\site-packages\pip (python 3.7)
However, I am using Anaconda for a virtual environment, and PyCharm as my IDE. I have included a screenshot of the projects interpreter for a good measure.Project Interpreter
Furthermore, I have checked that I have pip installed it on both the root and the environment.Root Environment
I think, you have multiple python versions installed.(2.* | 3.*)
You are installing packages in one python version and using another python version.
EDIT:
You can use pip2 install modulename for python2
and pip3 install modulename for python3

Python numpy update from 1.6 to 1.8

I have installed numpy 1.8. But when I do print numpy.__version__ it says 1.6.
What do I have to change to get python to realize where numpy is? Working on a Mac (10.9). I'm using python 2.7.6.
Edit:
I've tried to delete all my versions of numpy. I did pip uninstall numpy. And then I typed:
python
import numpy
print numpy.version
and it printed out 1.6.2
I can't delete numpy apparently.
I am running Python 2.7.5 on Mac OS X 10.9.4, and this appears to be some kind of weird bug in how the Macintosh factory-installed version of Python is handling upgraded package installations.
In my case, when I do:
sudo pip uninstall numpy
it removes the version of numpy installed under
/Library/Python/2.7/site-packages
However, this does not mean that numpy is fully removed from the system! There are a second set of "backup" versions of several Python packages installed also at:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
When I install numpy using the /usr/bin/easy_install utility that Apple shipped with the OS X system, the latest version (currently at 1.9.0, as of this posting) of numpy is loaded into Library/Python/2.7/site-packages, just as one would expect, and it correctly precedes the "OS X system default" version of numpy in the module load path so that the latest version of numpy is loaded when I do import numpy in Python. However--and this is the really weird, apparently buggy behavior!--when I uninstall numpy, and instead reinstall using either pip, or by doing:
sudo python setup.py install
on a .tar.gz distribution downloaded directly from sourceforge, the upgraded installation does not appear to take precedence in the Python module load path, even though it is also installed under /Library/Python/2.7/site-packages!
Anyway, to fix the problem (or rather, I should probably say, to work around the bug, at least on Max OS X), follow this procedure:
Uninstall the numpy package from /Library/Python/2.7/site-packages using the method of your choice (pip uninstall numpy appeared to work for me)
Verify that there is indeed no longer any numpy package still remaining under /Library/Python/2.7/site-packages
Reinstall numpy using the factory-included /usr/bin/easy_install. Do not use any other alternative method, at least not if you want to use numpy with the Apple factory-installed version of Python 2.7
Alternatively, using a completely different distribution of Python (e.g., Canopy or Anaconda), as one of the other commenters already mentioned, should also work as well.
You mentioned in the comments that removing with pip and OS package manager didn't work for you. If you may have used easy_install in the first place, also try easy_install -m for removal. If all else fails, you can clobber the files manually (the imports are taken from sys.path so the first version found in that list is where the import will come from).
Load up interactive python interpreter and check the physical location of the files:
>>> import numpy
>>> numpy.__file__
'/home/wim/.virtualenvs/xyz/local/lib/python2.7/site-packages/numpy/__init__.pyc'
This will tell you which directory you need to delete in order to prevent the unwanted version from being imported.
This is a somewhat impolite way to "uninstall" numpy, so use as a last resort.
I assume you have inconsistent version of numpy in two paths
/Library/Python/2.7/site-packages
and
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
My solution is rename (or delete) the one you don't like (possibly the older version) and symlink the other (the newer version) back to the directory which you deleted numpy folder from.

ValueError: numpy.dtype has the wrong size, try recompiling

I just installed pandas and statsmodels package on my python 2.7
When I tried "import pandas as pd", this error message comes out.
Can anyone help? Thanks!!!
numpy.dtype has the wrong size, try recompiling
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\analytics\ext\python27\lib\site-packages\statsmodels-0.5.0-py2.7-win32.egg\statsmodels\formula\__init__.py",
line 4, in <module>
from formulatools import handle_formula_data
File "C:\analytics\ext\python27\lib\site-packages\statsmodels-0.5.0-py2.7-win32.egg\statsmodels\formula\formulatools.p
y", line 1, in <module>
import statsmodels.tools.data as data_util
File "C:\analytics\ext\python27\lib\site-packages\statsmodels-0.5.0-py2.7-win32.egg\statsmodels\tools\__init__.py", li
ne 1, in <module>
from tools import add_constant, categorical
File "C:\analytics\ext\python27\lib\site-packages\statsmodels-0.5.0-py2.7-win32.egg\statsmodels\tools\tools.py", line
14, in <module>
from pandas import DataFrame
File "C:\analytics\ext\python27\lib\site-packages\pandas\__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
File "numpy.pxd", line 157, in init pandas.tslib (pandas\tslib.c:49133)
ValueError: numpy.dtype has the wrong size, try recompiling
(to expand a bit on my comment)
Numpy developers follow in general a policy of keeping a backward compatible binary interface (ABI). However, the ABI is not forward compatible.
What that means:
A package, that uses numpy in a compiled extension, is compiled against a specific version of numpy. Future version of numpy will be compatible with the compiled extension of the package (for exception see below).
Distributers of those other packages do not need to recompile their package against a newer versions of numpy and users do not need to update these other packages, when users update to a newer version of numpy.
However, this does not go in the other direction. If a package is compiled against a specific numpy version, say 1.7, then there is no guarantee that the binaries of that package will work with older numpy versions, say 1.6, and very often or most of the time they will not.
The binary distribution of packages like pandas and statsmodels, that are compiled against a recent version of numpy, will not work when an older version of numpy is installed.
Some packages, for example matplotlib, if I remember correctly, compile their extensions against the oldest numpy version that they support. In this case, users with the same old or any more recent version of numpy can use those binaries.
The error message in the question is a typical result of binary incompatibilities.
The solution is to get a binary compatible version, either by updating numpy to at least the version against which pandas or statsmodels were compiled, or to recompile pandas and statsmodels against the older version of numpy that is already installed.
Breaking the ABI backward compatibility:
Sometimes improvements or refactorings in numpy break ABI backward compatibility. This happened (unintentionally) with numpy 1.4.0.
As a consequence, users that updated numpy to 1.4.0, had binary incompatibilities with all other compiled packages, that were compiled against a previous version of numpy. This requires that all packages with binary extensions that use numpy have to be recompiled to work with the ABI incompatible version.
For me (Mac OS X Maverics, Python 2.7)
easy_install --upgrade numpy
helped. After this you can install up-to-date packages pandas, scikit-learn, e.t.c. using pip:
pip install pandas
I found it to be a simple version being outdated or mismatch and was fixed with:
pip install --upgrade numpy
pip install --upgrade scipy
pip install --upgrade pandas
Or might work with the one liner:
pip install --upgrade numpy scipy pandas
I had a similar error with another library and realized that I had several versions of numpy installed on my system. The fix for me was to edit my PYTHONPATH and put the site-packages that contained the latest version of numpy in first position.
As in here, for me only sudo pip install pandas==0.13.1 worked
I also encounter this error when use pandas to access MYSQL.
This error message indicates a binary compatible issue and can be resolved by
using latest version of pandas and numpy package.
Here is my steps to resolve this issue, and it works well on my Ubuntu 12.04:
cd /tmp/
wget https://pypi.python.org/packages/source/p/pandas/pandas-0.12.0.tar.gz
tar xzvf pandas-0.12.0.tar.gz
cd pandas-0.12.0
easy_install --upgrade numpy
In my case, I had installed pandas-0.10.0.win-amd64-py2.7 but was checking to see if a bug had been fixed in a more recent version of pandas. So I did an easy_install -U to force the upgrade, but then got the above error due to some incompatibilities with numpy etc... when I did
import pandas
To fix, I just reinstalled the pandas-0.10.0.win-amd64-py2.7 binary and everything works. I didn't see this answer (suggests to use pip) which may have helped me (though not sure) Install particular version with easy_install
Also this highlights why one should use virtualenv (which I wasn't).
For me (Mac OS X Mavericks) it worked to install the version for python2.6:
sudo port install py26-scikit-learn
then run:
python2.6 myscript.py
The problem I solved on Webfaction was old numpy library(1.5) which was in conflict with my fresh
pip install pandas
installation in .virtualenv.
The problem was solved after I did pip install pandas out of the virtual environment.
The idea came from discussion on https://github.com/pydata/pandas/issues/3711, thanks, cpcloud!
I just meet this 'ValueError' issue and have addressed it. Definitely there's something wrong with numpy package.
But when I try to pip install --upgrade numpy it failed, so I uninstall and download the newest numpy.zip file.
Then manually uncompress and python setup.py install it.
Luckly, it works!
Like #user333700 said, required versions of libraries may not meet for each other. You get one library as another's dependency. Then without knowing it was already installed as dependency, you need that specific library and you install one version. With such ways dependencies may mess up.
I lived such a case and looked for a solution. Found this:
https://stackoverflow.com/a/12975518/1694344
I had two different versions for egg-info file and folder name of numpy:
drwxr-xr-x. 19 root root 4096 Sep 25 15:00 numpy
drwxr-xr-x. 2 root root 4096 Sep 22 11:25 numpy-1.13.1.dist-info
-rw-r--r--. 1 root root 1630 Nov 20 2015 numpy-1.7.1-py2.7.egg-info
I removed them all and reinstalled numpy with pip.
I had a similar issue, and simply re-installing using pip install ... as suggested in previous comments didn't work.
What worked for me was re-installing with the added flag pip install --no-cache-dir ..., seems there was an incompatible numpy version somewhere in the cache.
There are cases where you want to keep a specific NumPy version and the upgrade option mentioned here will not work.
An example that occurred to me was the Python distribution preinstalled with ArcGIS. For ArcPy to work in ArcGIS 10.5.1, that distribution needs to be Python 2.7.12 with NumPy 1.9.3 and any other version of NumPy is probably going to cause issues with your ArcPy functionality.
What you can do with this case is try to install a specific, older version of the problematic third-party library that is supposed to be compatible with the older NumPy version that ArcGIS has.
For instance, scikit-learn 0.19.1 would NOT operate with NumPy 1.9.3 and would result in the same error you mentioned. However, scikit-learn 0.15 works fine. You can test different versions to find the one that works. Just mention the version number through pip:
python -m pip install scikit-learn==0.15

Categories