Numpy fails to serve as a dependency for pandas - python

I was trying to use pandas (installed the binaries and dependencies using conda, then using pip, then built then using no-binaries option); still getting error.
Numpy is available (1.11.2).
I understand some interface is not provided by numpy anymore.
Python version I am using is 2.7.11.
List of packages installed are bellow.
Error message:
C:.....Miniconda2\lib\site-packages\numpy\core__init__.py:14: Warning:
Numpy built with MINGW-W64 on Windows 64 bits is experimental, and
only available for testing. You are advised not to use it for
production.
CRASHES ARE TO BE EXPECTED - PLEASE REPORT THEM TO NUMPY DEVELOPERS
from . import multiarray Traceback (most recent call last): File
"io.py", line 2, in from data import support File
"....\support.py", line 3, in import pandas File
"....Miniconda2\lib\site-packages\pandas__init__.py", line 18, in
raise ImportError("Missing required dependencies
{0}".format(missing_dependencies)) ImportError: Missing required
dependencies ['numpy']

I would recommend not building from source on Windows unless you really know what you're doing.
Also, don't mix conda and pip for numpy; numpy is treated specially in conda and really should work out of the box. If you get an error on import pandas there's likely something wrong with your PATH or PYTHONPATH.
I suggest that you just create an empty conda env, and install only pandas in it. That will pull in numpy. If that somehow does not work, let's see if we can help you debug that.

Related

MAC Python 3.8 IntelliJ error while importing panda module

In my Apple M1 chip machine, trying to import panda module in IntelliJ IDEA. while running this program its giving below error.
If I run the same program in command line, it works. Running into this problem while running in the IDE.
Any help to resolve this error message?
Code
import os
import pandas as pd
Remove my home dir from this output:
Error
Traceback (most recent call last):
File "panda-test01.py", line 9, in <module>
import pandas as pd
File "Library/Python/3.8/lib/python/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
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.8 from "/Library/Developer/CommandLineTools/usr/bin/python3"
* The NumPy version is: "1.22.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: dlopen(Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 0x0002): tried: 'Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
Thanks
from your error message:
(mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
It's a little ambiguous as it could be interpreted either way round, but I think it means that IntelliJ is running using Rosetta2 in X86 mode, whereas the numpy/pandas installation the python PATH has is your arm version. (The alternative is the reverse of this, but this way round is more likely).
In order to run your program, you'll need to create a python environment which uses Rosetta2 and installs X86 binaries instead of arm. I've written about how to do this here as a reference for myself. Then IntelliJ should have a setting somewhere to specify the python environment to use for execution and debugging, you should set that environment/PATH to your new X86 environment.

How to use Python modules for interactive scripting in Valor NPI tool

I am trying to interact with a tool called Valor NPI using a Python script. This tool is used for designing and manufacturing electronic goods. As my first step, I ran a simple "hello world" program and it's running fine. But when I try to run some script using Python modules, it is showing a ModuleNotFound error. To resolve this problem, I've put the required modules and pip manually in that location (\Valor\vNPI_114\edir\all\python). Then, to check if it worked, I wrote a small script using the numpy module and tried to run it in that Valor tool. But it is showing the following error:
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/MentorGraphics/Valor/vNPI_DIR/sys/scripts/numpy1.py", line 2, in <module>
import numpy as np
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\__init__.py", line 150, in <module>
from . import core
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\core\__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
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.8 from "C:\MentorGraphics\Valor\vNPI_114\edir\nv\deps\Python\python.exe"
* The NumPy version is: "1.21.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
How can I solve this? How can I use Python modules in that tool?
Python packages are installed in different ways, usually using pip, sometimes using a setup.py, but generally not by just coping a module to your Python directory. In most cases, that won't work.
I have no experience with the Valor NPI tool, and I recommend first searching for documentation of that tool if it supports third-party Python modules. Maybe there is a recommended way of installing.
Otherwise, I think you should install the needed modules using pip for this specific Python installation. In your case, I would execute:
C:\MentorGraphics\Valor\vNPI_114\edir\nv\deps\Python\python.exe -m pip install numpy
And likewise for other packages that you need (replacing numpy by the corresponding module). Since you already copied numpy to your Python directory, you should remove that to avoid conflicts between the different copies.
It looks like it could not find _multiarray_umath.cp310-win_amd64.pyd under your numpy/core folder.
Like #wovano, I suggest you install the module through pip instead of copying the module folder. Sometimes it can work, sometimes will not.
You can follow these steps:
In the terminal create a virtual environment through the command of
python -m venv .venv
use the Python: Select Interpreter command from the Command Palette
(Ctrl+Shift+P) to select the virtual environment .venv
Create a new terminal(Ctrl+Shift+`) that will activate the .venv virtual environment automatically
install the NumPy with the command of pip install numpy
You can refer to this official doc for the detailed steps.

Separate versions of Python on same computer won't import same modules

I've been coding in Python 3.7.2 as my usual, but an API that I really want for my code only supports up to 3.6 (and does not support 2.7). I downloaded Python 3.6.4 to my computer, which also downloads a separate instance of the IDLE (not a problem). If I try to import something like numpy to my code in 3.7 (ex. import numpy as np) then it works as expected. However, if I do the same in the 3.6 IDLE I get:
Traceback (most recent call last):
File "", line 1, in
import numpy as np
ModuleNotFoundError: No module named 'numpy'
I think that it's a path problem but I'm unsure on how to fix it, and I can't find a solution to this problem elsewhere. Any help is appreciated, thanks.
Step 1: Get the location of the python executable from IDLE
import sys
print(sys.executable) # e.g. /Users/jk/.../bin/python
Step 2: Run the pip in the same folder as the one returned above.
/Users/jk/.../bin/pip install numpy
P.S. It's better to maintain libraries independently for each distribution, or even better use virtualenv or conda to create environments.
Try to install numpy specifically for python3.6:
python3.6 -m pip install numpy

ImportError: Numpy when importing pandas in virtual environment

I am receiving a weird error, which I think is due to different python versions installed on my machine. I used Python 3.7 and Anaconda Python 3.6. In anaconda I set up a virtual environment which has pandas installed as a package. Nevertheless, I cannot load it as there is an error with numpy. I tried instaling/uninstalling the packages many times and also uninstalled and installed anaconda and python, but still the error occours.
I am working on windows 10.
This is the error
Traceback (most recent call last):
File "C:/Users/USER/Desktop/test.py", line 1, in <module>
import pandas as pd
File "C:\Users\USER\AppData\Local\conda\conda\envs\freelancetrade\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
This is the very basic code i am executing:
import pandas as pd
print("done")
As I mentioned I tried different solutions - but nothing helped so far. And also all packages are installed.
Any good idea to solve this?
Cheers Harry

How to solve pandas import error in pycharm?

I've already install pandas from either the terminal and add pandas in pycharm project interpreter. However, every time I run a program which uses pandas it keeps reminding me there's an error.
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
File "/Users/Rabbit/PycharmProjects/NLP/review2vector.py", line 7, in <module>
from pandas import DataFrame
File "/Users/Rabbit/Library/Python/2.7/lib/python/site-packages/pandas/__init__.py", line 35, in <module>
"the C extensions first.".format(module))
ImportError: C extension: numpy.core.multiarray failed to import not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
I also followed this question's answer How to solve import error for pandas? But it does not work for me.
These issues can be easily avoided if you use a virtual environment to install and maintain your Python packages. Please refer to the link here for more information: LINK
The error message is telling you that numpy is not fully installed. There isn't enough information there to guess specifically what is wrong, but if I was troubleshooting I would use my package manager (pip probably) to uninstall and then re-install numpy and pandas. I would do numpy separately so that I could watch the messages. The numpy page says that they should have pre-compiled wheels available, so it just seems like a version mismatch.
Pycharm lets you install packages into a virtualenv easily and ensure that env is always activated when you open the pycharm terminal (great!) but it also makes it very hard to notice install errors.

Categories

Resources