numba not working because of an inconsistency with numpy - python-3.x

I have been stuck with this problem since a couple of days ago. I wanted to use numba for a project, so I created a conda environment in python=3.10.4
conda create -n scycom
Then I install the packages I need from the main repository
conda install numpy scipy numba matplotlib jupyter
which results in the installation of numpy=1.21.5 and numba=0.55.1
When I am done installing I run jupyter lab jupyter lab --port=8888 and create a notebook. When I type from numba import jit, I get the following error message
ImportError: Numba needs NumPy 1.21 or less
with a problem apparently arising with _ensure_critical_deps(). This is puzzling because numpy is version 1.21.5.
My attempts to fix this problem
Given that it seemed a compatibility issues, I tried downgrading to numpy=1.20.1 but the problem persists and, sometimes, other compatibility issues with glib show up. In fact, the exact same error message arises
I created an environment with python=3.8.13, with numpy=1.20.1 and numba=0.55.1, facing the exact same error messages
I tried different combinations of libraries but I could solve this incompatibility
I tried a few internet solutions but I did not find that any really fit into my problem
I hope somebody willing to help has faced and solved a similar issue

Related

Cannot import torch Error loading ..\caffe2_nvrtc.dll" or one of its dependencies

I am on a Windows 10 64 bit system.
Pytorch for cuda has been working successfully for some time.
Today I tried to upgrade to the latest version of Pytorch (1.13) using
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
Now I cannot import torch. I get the error:
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\alan\anaconda3\lib\site-packages\torch\lib\caffe2_nvrtc.dll" or one of its dependencies.
I have tried both in a Jupyter notebook and in the Spyder IDE.
I have tried completely removing Anaconda and reinstalling afresh and then reinstalling Pytorch with no success.
I do not believe I have any other versions of python installed.
The offending dll (caffe2_nvrtc.dll) does seem to be in the file location specified.
I have found various similar problems reported but they all date back to 2020 or earlier and none of them seemed to have a satisfactory solution.
Can anyone point me in the correct direction
I still do not understand why using conda did not work but I tried again using pip
and that did work
I experienced the same problem as yours today.
It turns out that when I use the anaconda prompt then the problem disappears.
Anaconda prompt could do it
Then I speculated that the only difference between these two scenarios is that when I use the anaconda prompt, I use the base anaconda environment, probably somehow the conda environment in spyder is not activated.
So the solution is to open the spyder in anaconda prompt like this:
Then it works.
This picture will tell you the cause for the problem.
problem...

Problem with importing matplotlib in python

I have matplotlib installed. I double checked it if its there using conda list and pip list commands.
However, when I am importing it, it says the error 'ModuleNotFoundError: No module named 'matplotlib''
Now, I typically understand what it this error means and as mentioned, I have it installed. But the issue persist.
What can be my starting point to sort this issue?

How do I fix a keras error for a plaidbench keras test?

I am trying to install plaidml-keras so I can use non-Nvidia GPUs with Keras in python/jupyter. After clearing several other hurdles I get as far as:
plaidbench keras mobilenet
but it errors twice
ImportError: cannot import name 'object_list_uid' from 'keras.utils.generic_utils' (/Users/me/sprinthive/src/notebooks/nbenv/lib/python3.7/site-packages/keras/utils/generic_utils.py)
File "/Users/me/sprinthive/src/notebooks/nbenv/lib/python3.7/site-packages/plaidbench/frontend_keras.py", line 321, in __init__
raise core.ExtrasNeeded(['plaidml-keras'])
plaidbench.core.ExtrasNeeded: Missing needed packages for benchmark; to fix, pip install plaidml-keras
This is in spite of already having plaidml-keras installed:
pip freeze | grep plaid
plaidbench==0.6.4
plaidml==0.6.4
plaidml-keras==0.6.4
[I am using 0.6.4 to make it work on macOS 10.13 High Sierra]
How can I resolve the above errors?
Thanks!
I worked this out by creating a virtual environment with Anaconda. Beware that i am working on Windows, so this might not be a solution for your problem. If i had to guess, something was installed by me before that causes a python package problem. I think this is related to the tensorflow library, but i haven't dug into that. I would recommend trying out a fresh virtual environment on your Mac, where you install the plaidml package. The error Message before was exactly the same.

ImportError: Unable to import required dependencies: numpy: error when trying to migrate

I am using Django and Python with Anaconda. At the beginning, I was able to migrate by the addition of a sqlite3.dll file. However, when I try to migrate again, it gives me this error. I have tried uninstalling and installing both numpy and pandas in Project Interpreter. I'm using Pycharm and I'm using Conda Package manager with the Conda environment. I also tried migrate --run-syncdb but it still gives me the error.
How would I fix this to be able to use .objects.bulk_create()?
To fix .objects.bulk_create(), one recommendation was to run migrate --run-syncdb and I cannot run it currently because of the error below.
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 "C:\Users\PuTung\anaconda3\envs\swe_project\python.exe"
* The NumPy version is: "1.19.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.```

Unable to import sklearn and statsmodels from Anaconda from windows 10 pro

I'm relatively new to python, so please excuse my ignorance on what could be a very easy fix. I am running python 3.6 through the Rodeo IDE, and it has been great, as it is similar to R-Studio (which I am very familiar with). As an aspiring data scientist, I am trying to learn how to fit regression and time series models to data, and all of the tutorials that I have found all say that I need various packages, all of which should be included in the Anaconda library. After downloading and re-downloading Python, Rodeo, and Anaconda, and trying various online fixes, I have been unable to successfully load the scikit-learn and the statsmodels modules.
#here is everything I have tried.
#using pip
! pip install 'statsmodels'
! pip install 'scikit-learn'
! pip install 'sklearn'
I don't get any errors here, and to be honest I'm kind of confused as to what this actually does, but I have seen many people online always suggest that this is a big problem when trying to import modules.
#using import
import sklearn
import statsmodels
from sklearn import datasets
import statsmodels.api as sm
all of the above give me the same error:
import statsmodels.api as sm
ImportError: No module named 'statsmodels'
ImportError: Traceback (most recent call last)
ipython-input-184-6030a6549dc0 in module()
----> 1 import statsmodels.api as sm
ImportError: No module named 'statsmodels'
I have tried to set my working directory to the Anaconda 3 file that has all of the packages and rerunning the above code with no success.
I'm thinking that the most likely problem has to do with my inexperience, and it is probably a simple fix. Is it possible that the IDE is bad or anaconda just doesn't like me?
So keeping all of the above in mind, the question is, how can I import these modules successfully so that I can access their functionality?
Option 1:
After installing packages with pip, try closing and reopening your IDE/Jupyter Notebook and try again.
This is a known bug that Jake VanderPlas outlined here
Option 2:
Don't put quotations around your pip messages.
!pip install -U statsmodels
!pip install scikit-learn
Option 3:
Also are you using Anaconda? If you are, you should already have scikit-learn. If you are trying inside Rodeo, I think you need to set your path inside Rodeo. Open Rodeo and set the Python Path to your fresh anaconda. See here

Resources