Python Pandas - Lack of Required Dependencies ['numpy'] 1

Since yesterday, I had this error while trying to import packages into anaconda:

ImportError: Missing required dependencies ['numpy']

I tried disabling Anaconda and Python by switching to Python 2.7, but nothing works for the same error, here is the code I get:

enter image description here

Any help really appreciated!

+44
source share
31 answers

I had the same problem right after updating pandas to 0.19.2. I fixed this with the following install / uninstall from the Windows cmd line:

 pip uninstall pandas -y pip uninstall numpy -y pip install pandas pip install numpy 

This also violated my matplotlib installation, so I also uninstalled / installed it.

Very strange behavior for a seemingly routine update.

+43
source

I had to install this other package:

 sudo apt-get install libatlas-base-dev 

This seems like a numpy dependency but pip or apt-get do not install it automatically for any reason.

+8
source

What happens if you try to import numpy?

You tried'

 pip install --upgrade numpy pip install --upgrade pandas 
+7
source

I had this problem with the latest version of numpy 1.16.x

Problem resolved with

python3 -m pip uninstall numpy

python3 -m pip install numpy==1.14.0

+6
source

Have you installed miniconda and pandas without dependencies?

Try installing numpy first with conda install numpy or pip install numpy .

If you are on Windows, you can get precompiled versions of most libraries that require compilation from here .

+3
source

The pandas data manipulation capabilities are built on top of the numpy library. In a sense, numpy is a dependency of the pandas library. If you want to use pandas, you have to make sure you have numpy too. When you install pandas using pip , it automatically installs numpy. If it is not, try the following

pip install -U numpy pandas

For conda

conda install numpy pandas

+2
source

I also ran into the same problem. This happened to me after I updated my numpy library. This was solved in my case by updating my pandas library, and also after updating my numpy library with the following command:

 pip install --upgrade pandas 
+2
source

On Windows 10, Anaconda3-5.3.0-Windows-x86_64 I had the error Missing required dependencies ['numpy'] errors when running scripts, %HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe pandas_script_foo.py .

In my case, the error was caused by the lack of Anaconda package PATH definitions when running Anaconda python.exe in a cmd.exe windows session. The numpy package is missing. It simply cannot be found in PATH.

Installing Anaconda includes keyboard shortcuts that provide examples of how to configure PATH to run the script. See Shortcuts in %HOMEPATH%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit) . See %HOMEPATH%\AppData\Local\Continuum\anaconda3\cwp.py for how Anaconda configures PATH.

Below is an example of a Windows BAT file that calls cwp.py to configure PATH and then runs a python script. Its copy of the commands executes the Anaconda jupyter-lab shortcut.

 %HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe ^ %HOMEPATH%\AppData\Local\Continuum\anaconda3\cwp.py ^ %HOMEPATH%\AppData\Local\Continuum\anaconda3 ^ %HOMEPATH%\AppData\Local\Continuum\anaconda3\python.exe ^ %HOMEPATH%\AppData\Local\Continuum\anaconda3\Scripts\jupyter-lab-script.py 

If you need to run python scripts on Anaconda with support for running a BAT file, the above example BAT file should do the trick.

+2
source

Use your own environment

 $ virtualenv env $ source env/bin/activate $ pip uninstall pandas $ pip uninstall numpy $ pip install pandas $ pip install numpy 
+1
source

I had the same problem. This is because I have installed several versions of numpy . Uninstall all versions using several times:

pip uninstall numpy

Then reinstall it using the command:

pip install numpy

+1
source

First, try importing numpy yourself, like so:

 import numpy as np 

I received this message:

 ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['/home/michael/.local/lib/python3.6/site-packages/numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version. 

So do what it says, keep deleting numpy until it is gone, and then reinstall.

It worked for me.

+1
source

I had the same problem when using Microsoft Visual Code with Python 3.7.3 64-bit ("base": conda) as my Python interpreter. Before executing any code, enter the following three commands:

 C:/ProgramData/Anaconda3/Scripts/activate #activate conda Scripts directory conda activate base #activate conda & C:/ProgramData/Anaconda3/python.exe #to run python 
+1
source

I had the same problem with the anaconda package, it was updated.

 anaconda {4.3.1 -> custom} ## I am not sure if this was the issue 

Click below to find out

 conda list --revisions 

what i did is just uninstall pandas using conda and reinstall it

 conda install pandas 

Some new libraries may also be installed with it.

It worked for me, hopefully does the same for you.

0
source

Remove any package packages that you encounter. Manually delete all package site files. If you are using MacPorts, sudo port clean.

Then try reinstalling. Sometimes there are files that should have been deleted, but not if the installation was abruptly interrupted or something like that.

There may be a problem with conflicting versions of the package (s), as well as potentially problems with Pathing. Are you sure you have set the correct path for your binaries? (/ opt / local / bin, / anaconda2 / bin, etc.)

Another problem might be PYTHONPATH, which is obviously looking for the wrong place for the file.

0
source

I recently had the same issue with Anaconda with Python 3.7.

I solved this problem by downgrading the python version to 3.6:

 conda install python=3.6 

and then, updating all the packages:

 conda update --all 
0
source

pandas is built on top of numpy, so you need to have numpy to use the data processing function, so install numpy first.

 pip install numpy 
0
source

This worked in my anaconda environment, but I do not know why conda does not work. For some reason, conda uninstall was not enough. This only worked with conda remove .

 conda remove pandas conda remove numpy conda install pip pip install pandas 

* With this answer

This triggers the following import warning in python 3.6 and 3.7:

 ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__ 

If you want to ignore this warning (and possibly other ImportWarning ), add the following to your script before importing pandas:

 import warnings warnings.filterwarnings('ignore', category=ImportWarning, module='_bootstrap.py') 
0
source

In my case, even though I used the above options for uninstalling and installing using pip, the code still gave me the same errors.

Finally, I created a virtual environment and installed numpy and pandas using pip in my virtual environment. Now the code is working.

Steps: for Anaconda3 - Please change according to your installation type: [if you do not have the env virtual package installed]

 $ pip install virtualenv 

[from the command line, go to the directory using c: \ anadonda3 \ scripts

[write the following command to use virtual env to create a virtual env for you in your chosen location]

 $virtualenv c:\anaconda3\envs\my_virtual_env 

[after creation you will need to activate your virtual environment]

 $c:\anaconda3\envs\my_virtual_env\scripts activate 

[pip now installs numpy and pandas and other necessary packages using pip]

[After installation is complete, exit the virtual environment]

 $c:\anaconda3\envs\my_virtual_env\scripts deactivate 

now use python.exe inside your env virtual folder to run the script, and it will work even with python 3.7.

0
source

Try:

  sudo apt-get install libatlas-base-dev 

This should work now.

Otherwise, try uninstalling and reinstalling numpy and pandas.

0
source

I solved this problem by downgrading the python version to 3.6 on venv, based on the advice of Xin Wang, edited by Skopchanov. The problem popped up on the .py initialization file

0
source

I use Win10 and Conda, and this problem is just added to me when updating python 3.7.2-h8c8aaf0_0 --> 3.7.2-h8c8aaf0_2 . I solved this by reverting to the previous version with

 conda install python=3.7.2=h8c8aaf0_0 
0
source

If you run your program on PyCharm on Windows, there is a known bug because PyCharm simply does not add env-related paths to PATH.

This issue has been fixed in preview assembly (EAP) 2019.1 .

For me, installing EAP fixed the problem.

0
source

There was the same error, and reinstalling numpy and pandas did not work. Turns out there were several installations of both, and I had to run pip uninstall numpy pandas several times until all the installations were removed. Then installed them again and it worked.

0
source

I didn’t succeed ... except when I found it

 I suspect that you have a local file called unittest.py that is getting imported instead of the standard module. 
0
source

I tried to upgrade Anaconda 2 to Anaconda 3. I tried installing Anaconda3-2018.12-Windows-x86 and Anaconda3-2019.03-Windows-x86_64 on my computer with Windows 10 and could not with this error. For me, using Anaconda3-4.4.0-Windows-x86_64 for Anaconda 3 worked by trying all the answers listed here.

0
source

I fixed this using Anaconda by going to Environments> base (root), doing a numpy search in the installed modules and clicking on it with a tick and selecting> Mark to install a specific version> 1.14.0 (as suggested by another user in this thread) , Then click Apply. As soon as it went down, I stopped getting errors when running py files on the command line.

Throughout this saga, I could still use https://pypi.org/project/auto-py-to-exe/ even when I received errors on the command line, but it was difficult to create exe every time I wanted to check changes. Now everything is sorted. I think there was a problem with NumPy 1.16.4.

In any case, I hope this helps someone who also uses Anaconda.

0
source

The following worked for me. The folders for numpy and pandas along with their contents are completely removed from the site-packages folder. Check depending on whether you are using python2 or python3. Check the exact path according to your car.


Use caution with the rm -rf command. If you are not sure what you are doing, please do it manually using any file manager of your choice!

  1. rm -rf ~ / anaconda2 / envs / myenv / lib / pythonX / site-packages / pandas *

  2. rm -rf ~ / anaconda2 / envs / myenv / lib / pythonX / site-packages / numpy *

Then I installed clean packages for pandas and numpy as usual with

  • pip install numpy
  • pip install pandas
0
source

I have got the same error recently.
Before you apply the removal or installation tools, try updating Jupyter.

How? Go to the "Media" section and enter "pandas" in the package search box.
After that check the version (if this column shows a blue number with a diagonal arrow, this means that your pandas are out of date).
Click "pandas" and the option will appear (select "Apply" and wait a couple of minutes to update the package).
And then do a quick test on any laptop to make sure your Jupyter runs smoothly.

0
source

build_exe_options = {"packages": ["os",'pandas','numpy']}

It is working.

-2
source

I solve this problem with these commands.

  1. Konda remove numpy
  2. Konda remove pandas
  3. Konda Pip Update
  4. pip install numpy
  5. pip install pandas

maybe there is some kind of problem with numpy in conda, I use pip to install numpy and pandas, everything is fine

-2
source

Source: https://habr.com/ru/post/1263352/


All Articles