I am trying to use Biopython using anaconda and the Jupiter notebook with Python3.
However, simply import numpy gives the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/__init__.py:23, in <module>
22 try:
---> 23 from . import multiarray
24 except ImportError as exc:
File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/multiarray.py:10, in <module>
9 import functools
---> 10 from . import overrides
11 from . import _multiarray_umath
File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/overrides.py:6, in <module>
4 import os
----> 6 from numpy.core._multiarray_umath import (
7 add_docstring, implement_array_function, _get_implementing_args)
8 from numpy.compat._inspect import getargspec
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-39-darwin.so' (no such file)
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
Input In [2], in <module>
----> 1 import numpy
File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/__init__.py:144, in <module>
141 # Allow distributors to run custom init code
142 from . import _distributor_init
--> 144 from . import core
145 from .core import *
146 from . import compat
File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/__init__.py:49, in <module>
25 import sys
26 msg = """
27
28 IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
(...)
47 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
48 __version__, exc)
---> 49 raise ImportError(msg)
50 finally:
51 for envkey in env_added:
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.9 from "/usr/local/bin/python3"
* The NumPy version is: "1.22.1"
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/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-39-darwin.so' (no such file)
I have tried everything I know:
Unsintall and install numpy again.
I did the same for Biopython.
I am working on my created and activated environment called dissertation.
I have checked the not useful website for numpy but nothing seems to be working for Mac OS and Jupiter Notebook.
I have checked that Python, anaconda, Biopython and numpy are all updated.
I even uninstalled and installed anaconda.
Any idea what's causing this problem? I AM USING macOS Monterey version 12.1 with the Apple M1.
Related
Ok, there are multiple similar errors and no conclusive solution:
System: windows 10, conda 4.10.3, python 3.7.11
In cmd I activated conda virtual environment: conda activate tensorflow
I ran
import vtk
and got back:
ImportError Traceback (most recent call last)
D:\user_data\Program_Files\Anaconda3\envs\tensorflow\lib\site-packages\vtkmodules\vtkCommonCore.py in <module>
4 # use relative import for installed modules
----> 5 from .vtkCommonCorePython import *
6 except ImportError:
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_3128/2084281522.py in <module>
----> 1 import vtk
D:\user_data\Program_Files\Anaconda3\envs\tensorflow\lib\site-packages\vtk.py in <module>
30 all_spec = importlib.util.find_spec('vtkmodules.all')
31 all_m = importlib.util.module_from_spec(all_spec)
---> 32 all_spec.loader.exec_module(all_m)
33
34 # import vtkmodules
D:\user_data\Program_Files\Anaconda3\envs\tensorflow\lib\site-packages\vtkmodules\all.py in <module>
5
6 # --------------------------------------
----> 7 from .vtkCommonCore import *
8 from .vtkCommonMath import *
9 from .vtkCommonMisc import *
D:\user_data\Program_Files\Anaconda3\envs\tensorflow\lib\site-packages\vtkmodules\vtkCommonCore.py in <module>
7 # during build and testing, the modules will be elsewhere,
8 # e.g. in lib directory or Release/Debug config directories
----> 9 from vtkCommonCorePython import *
ModuleNotFoundError: No module named 'vtkCommonCorePython'
Previously in conda virtual environment I ran conda install vtk and it ran fine.
My path variable contains: D:\user_data\Program_Files\Anaconda3
I also searched and found the following folder: D:\user_data\Program_Files\Anaconda3\pkgs\vtk-8.2.0-py37h1e53df8_200
How else can I troubleshoot?
I tried
pip install tensorflow
it says it is incompatible with my numpy version(1.20.0)
Then I tried unistall numpy to required version numpy~=1.19.2
Then
pip install fancyimpute
It installed without any errors in AnacondaPromt
But it still not working in Jupyter Notebook
The Error is
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-34-e68ac4972d28> in <module>
16 import tensorflow as tf
17 import numpy.core.multiarray
---> 18 from fancyimpute import KNN
~\anaconda3\lib\site-packages\fancyimpute\__init__.py in <module>
2
3 from .solver import Solver
----> 4 from .nuclear_norm_minimization import NuclearNormMinimization
5 from .matrix_factorization import MatrixFactorization
6 from .iterative_svd import IterativeSVD
~\anaconda3\lib\site-packages\fancyimpute\nuclear_norm_minimization.py in <module>
11 # limitations under the License.
12
---> 13 import cvxpy
14
15 from .solver import Solver
~\anaconda3\lib\site-packages\cvxpy\__init__.py in <module>
16
17 __version__ = "1.1.10"
---> 18 from cvxpy.atoms import *
19 from cvxpy.constraints import NonPos, Zero, SOC, PSD
20 from cvxpy.expressions.expression import Expression
~\anaconda3\lib\site-packages\cvxpy\cvxcore\python\__init__.py in <module>
1 # TODO(akshayka): This is a hack; the swig-auto-generated cvxcore.py
2 # tries to import cvxcore as `from . import _cvxcore`
----> 3 import _cvxcore
ImportError: numpy.core.multiarray failed to import
I had the same issue and I upgraded NumPy by running pip install numpy --upgrade. It worked around for me.
I found a solution right here
Opencv/numpy issue: "module compiled against API version X but this version of numpy is Y"
Here is the table and since my version is 1.19.5(0xd) now,
I uninstalled this version and installed 0xe version of numpy which is 1.20.0.
I use TensorFlow 2.4 on Windows 10 with Python 3.8 (I have Python 3.9 and 3.6 installed too) within a virtual environment ml2u where only TensorFlow 2.4 is installed so far by pip install tensorflow. I get the error messages below by trying to import TensorFlow in a notebook. As recommended in other posts I have installed Microsoft visual C++ redistributable which led to the installation of MS Visual and VC_redist.x64.exe.
import tensorflow as tf
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-64156d691fe5> in <module>
----> 1 import tensorflow as tf
c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\__init__.py in <module>
37 # go/tf-wildcard-import
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
---> 39 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
40
41 from tensorflow.python.eager import context
c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
81 for some common reasons and solutions. Include the entire stack trace
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
----
The shell produced followint output while running jupyter:
[W 20:51:12.010 NotebookApp] Notebook Untitled.ipynb is not trusted
[I 20:51:14.060 NotebookApp] Kernel started: 0d0455bd-ade8-4128-b273-0b24e8d9228f, name: ml2u
You might be facing this issue because you are running 32-bit python or 32-bit OS. And also check does your CPU supports AVX instructions.
Please take a look at system requirements and check if you have correct dependencies installed.
whenever trying to import deep learning library like tensorflow, keras show error
import tensorflow
ImportError Traceback (most recent call last)
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-3-370f0fe8bb94> in <module>
----> 1 import tensorflow
~\anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
~\anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
37 # go/tf-wildcard-import
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
---> 39 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
40
41 from tensorflow.python.eager import context
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
81 for some common reasons and solutions. Include the entire stack trace
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\Gokul\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
While searching for your issue, I found the following:
https://github.com/tensorflow/tensorflow/issues/23683
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed
In my opinion, uninstall tensorflow, if you have installed it using pip and reinstall using conda.
conda install -c anaconda tensorflow
Modify to tensorflow-gpu in case you need that, and before executing above command, make sure you have created a fresh environment in conda. Do not install in base!
i am trying to import keras library after installing tensorflow gpu following the steps given in the below link,
https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/
and created an environment tf-gpu.
then i installed keras using pip install keras in that environment. But when i try to import keras in jupyter notebook, it gives below error,
'''
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
~\anaconda3\lib\site-packages\keras\__init__.py in <module>
2 try:
----> 3 from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
4 except ImportError:
~\anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
~\anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
39
---> 40 from tensorflow.python.eager import context
41
~\anaconda3\lib\site-packages\tensorflow\python\eager\context.py in <module>
34 from tensorflow.core.protobuf import rewriter_config_pb2
---> 35 from tensorflow.python import pywrap_tfe
36 from tensorflow.python import tf2
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py in <module>
27 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import
---> 28 from tensorflow.python import pywrap_tensorflow
29 from tensorflow.python._pywrap_tfe import *
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
ImportError: Traceback (most recent call last):
File "C:\Users\Mayank\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-4-88d96843a926> in <module>
----> 1 import keras
~\anaconda3\lib\site-packages\keras\__init__.py in <module>
3 from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
4 except ImportError:
----> 5 raise ImportError(
6 'Keras requires TensorFlow 2.2 or higher. '
7 'Install TensorFlow via `pip install tensorflow`')
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`
'''
and when i check the version of tensorflow it shows '2.1.0'
Can you someone please help us with this?
Best way is to uninstall keras and tensorflow so you get a fresh start or just create a new environment. Then install tensorflow using conda. Conda will install tensorflow 2.1.0, cuda toolkit 10.1.243 and cudnn 7.6.5. Pip does not install the toolkit or cudnn and you have to download these and change your environment path variables to point to the directories where they are stored. If you want to install tensorflow 2.2 first install tensorflow 2.1.0 with conda then use pip to install tensorflow 2.2 using pip install tensorflow ==2.2.0. Tensorflow 2.2 is compatible with the toolkit and cudnn versions installed by 2.1. Conda can install tensorflow only up to 2.1.0. Note you may want to create your new environment using python 3.7. Users have reported problems with 3.8 when installing tensorflow with conda. Tensorflow 2.0 and above includes Keras.