9
votes

In jupyter notebook I am running through this error. I am using py I just installed pytorch, previously it was working fine.

import pyodbc
import pandas as pd
import matplotlib.pyplot as plt

import warnings
warnings.filterwarnings('ignore')

When I run the above cell I got the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-1051f624fd0e> in <module>()
      1 import pyodbc
----> 2 import pandas as pd
      3 import matplotlib.pyplot as plt
      4 
      5 import warnings

C:\Anaconda3\lib\site-packages\pandas\__init__.py in <module>()
     29 
     30 try:
---> 31     from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
     32 except ImportError as e:  # pragma: no cover
     33     # hack but overkill to use re

C:\Anaconda3\lib\site-packages\pandas\_libs\__init__.py in <module>()
      1 # flake8: noqa
      2 
----> 3 from .tslibs import (
      4     NaT,
      5     NaTType,

C:\Anaconda3\lib\site-packages\pandas\_libs\tslibs\__init__.py in <module>()
      1 # flake8: noqa
      2 
----> 3 from .conversion import localize_pydatetime, normalize_date
      4 from .nattype import NaT, NaTType, iNaT, is_null_datetimelike
      5 from .np_datetime import OutOfBoundsDatetime

__init__.pxd in init pandas._libs.tslibs.conversion()

ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C header, got 192 from PyObject
6

6 Answers

7
votes

Which version of numpy do you have installed? I got the same error with 1.18.5, downgrading to 1.16.0 or 1.16.1 solved the issue. Also check which numpy version is required by pytorch, and any other library requiring numpy, I found pipdeptree quite useful for that.

5
votes

I was getting the same error, solved by upgrading Numpy

pip uninstall numpy ----> run it 2-3 times until you see "numpy not found"

install the latest Numpy by simple pip

pip install numpy 
4
votes

I got the same error but I had numpy 14.x. When I upgrade to 1.16.6, the error just disappeared. pip install numpy==1.16.6

3
votes

Wanted to add that I solved this for my environment by upgrading from python 3.6 to python3.8 and installing numpy 1.20

you may need to clear your cached package version from pip using pip cache purge .

1
votes

Updating numpy would solve this problem as mentioned in other answers as well. However, as of quantipy3 (latest==0.2.4) the numpy version to install would be 1.14.x. But I had to upgrade it to 1.16.x in order for quantipy to work. So this is what i did.

pip show -v numpy

Name: numpy
Version: 1.14.5
Summary: NumPy: array processing for numbers, strings, records, and objects.
Home-page: http://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /home/kusal/.local/lib/python3.8/site-packages
Requires: 
Required-by: scipy, quantipy3, pyarrow, pandas, azureml-dataset-runtime
Metadata-Version: 2.1
Installer: pip
Classifiers:
  Development Status :: 5 - Production/Stable
  Intended Audience :: Science/Research
  Intended Audience :: Developers
  License :: OSI Approved
  Programming Language :: C
  Programming Language :: Python
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.4
  Programming Language :: Python :: 3.5
  Programming Language :: Python :: 3.6
  Programming Language :: Python :: Implementation :: CPython
  Topic :: Software Development
  Topic :: Scientific/Engineering
  Operating System :: Microsoft :: Windows
  Operating System :: POSIX
  Operating System :: Unix
  Operating System :: MacOS

Then,

pip uninstall numpy

Finally,

pip install numpy==1.16.1

Quantipy would give an error as expected, saying the numpy version is incompatible. But for my use case it turned out ok. (I was making use of RIM and Dataset modules)

0
votes

Always better to create a fresh environment, especially when theano and pymc3. This is a part of my Jupyter Notebook, in my attempt to code along an example involving the above libraries / tools in the Bayesian Inference context.
Full Notebook might be soon on GitHub, but for now, I hope the following might help:

2. Make sure you apply the following instructions: Make sure that you follow all the instructions states in the following url:

https://github.com/pymc-devs/pymc3/wiki/Installation-Guide-(Windows)

I wasted a couple of hours trying to fix already existed installations. These exercises worth having on their own a fresh virtual environment.

In brief:

  1. ⚠ Do not pip install without first installing dependencies with conda. ⚠

  2. create a fresh environment in one step (in your Anaconda Prompt). I used:

"conda create -n pm3env -c conda-forge "python=3.8" libpython mkl-service m2w64-toolchain numba python-graphviz scipy"

  1. Activate your new environment:

"conda activate pm3env"

  1. After that, PyMC3 can be installed with:

"pip install pymc3" (HERE you may used pip - this is again in your Anaconda Prompt)

  1. Final part, uninstall theano As you can see from the messages above, what I have already got it is not compatible. "conda remove theano" and "conda install -c conda-forge theano-pymc"

YOU ARE READY TO GO!

  1. Note for now, I did not install the additional dependencies as stated in the above mentioned url. As you can see, it is not importing theano and PyMC3 with absolutely no errors.