ImportError: Numpy when importing pandas in virtual environment - python

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

Related

ModuleNotFoundError, even after pip install

I have recently bought a new laptop and was viewing some python projects of mine which I made on my pc. For one of them I use the python-bitvavo-api library which I installed using pip3 install python-bitvavo-api. The version I installed is 1.2.2 which is the latest on their website.
Now when I try to import it using this code: from python_bitvavo_api.bitvavo import Bitvavo, I get the following error:
Traceback (most recent call last):
File "C:\Users\indig\OneDrive\Documenten\Python Projects\Personal\Cryptone\Cryptone.py", line 6, in <module>
from python_bitvavo_api.bitvavo import Bitvavo
ModuleNotFoundError: No module named 'python_bitvavo_api'
I read online that it may occur when using multiple python versions, Im only using 1 and thats python 3.7
Btw. I have the same error with the Pillow module, so it might be a setting in visual studio that I dont know of. Anyway, someone please help. If you need more details please ask.
How are you running it? From the terminal or from VS?
You can also check the installed libraries running the command pip list

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.

Error while importing igraph

I am using Python 3.6 on Windows 7 and I have a problem with the igraph package. I was having errors while I was trying to install it using pip, so I decided to install it from the .whl file. Unfortunately, I couldn't find version appropriate for Python 3.6, so I downloaded another version and changed the name of the file so that it looked like it was designed for Python 3.6. The installation was successful, but when I am trying to run a script which uses the igraph module - a following error message appears:
Traceback (most recent call last):
File "C:/Users/Jarek/Documents/Studia/Programowanie/Python na studiach/Analysis of Unstructured Data/List2.py", line 6, in <module>
import igraph as ig
File "C:\Users\Jarek\AppData\Local\Programs\Python\Python36-32\lib\site-packages\igraph\__init__.py", line 34, in <module>
from igraph._igraph import *
ModuleNotFoundError: No module named 'igraph._igraph'
I haw a very similar issue under Python igraph import error on Windows
but there was no answer there. I have also seen
No module named 'igraph._igraph' but suggestion given there does not help me (or I do not know how to properly apply it).
Any help will be greatly appreciated. Thanks in advance.
I couldn't find version appropriate for Python 3.6, so I downloaded another version and changed the name of the file so that it looked like it was designed for Python 3.6.
So the trick didn't work. Use Python 2.6 or 2.7. Or compile from sources.

Numpy fails to serve as a dependency for pandas

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.

Trying to download modules but python can't find them

So I need some modules for a project and after trying a lot of things and googling a lot of things I still can't get it to work. I used this code to test if the module was working:
import sys
sys.path.append('c:\users\my name\anaconda2\lib\site-packages')
import numpy
x = randn(100,100)
And I got this error:
Traceback (most recent call last):
File "C:\Users\My Name\Desktop\test.py", line 3, in
import numpy
ImportError: No module named numpy
Any idea why I'm doing wrong?
You can try two things:
1) which python
And see what python you are using. You may be still pointing to old python the system has. In that case add ~/anaconda2/bin to $PATH environment variable.
2) sys.path.append('c:\users\my_name\anaconda2\lib\python2.x\site-packages')
Usually anaconda library is installed under lib\pythonx.x(the correct python version number)\site-packages. So change that.
If none of the above worked, then just do clean install from scratch all over again.

Categories

Resources