Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when importing tensorflow in jupyter notebooks #7

Open
floydjaggy opened this issue Jan 7, 2022 · 1 comment
Open

Error when importing tensorflow in jupyter notebooks #7

floydjaggy opened this issue Jan 7, 2022 · 1 comment

Comments

@floydjaggy
Copy link

when running the following block
import numpy as np
import pandas as pd
import sklearn
import tensorflow as tf
import matplotlib.pyplot as plt

Check for TensorFlow GPU access

print(f"TensorFlow has access to the following devices:\n{tf.config.list_physical_devices()}")

See TensorFlow version

print(f"TensorFlow version: {tf.version}")

i get the following error.

ImportError Traceback (most recent call last)
~/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/init.py in
21 try:
---> 22 from . import multiarray
23 except ImportError as exc:

~/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/multiarray.py in
11
---> 12 from . import overrides
13 from . import _multiarray_umath

~/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/overrides.py in
6
----> 7 from numpy.core._multiarray_umath import (
8 add_docstring, implement_array_function, _get_implementing_args)

ImportError: dlopen(/Users/floydjaggy/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 0x0002): Library not loaded: @rpath/libcblas.3.dylib
Referenced from: /Users/floydjaggy/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so
Reason: tried: '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/bin/../lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/bin/../lib/libcblas.3.dylib' (no such file), '/usr/local/lib/libcblas.3.dylib' (no such file), '/usr/lib/libcblas.3.dylib' (no such file)

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
/var/folders/fd/c7pllh790y9231d9wj4y6pym0000gn/T/ipykernel_13997/116520098.py in
----> 1 import numpy as np
2 import pandas as pd
3 import sklearn
4 import tensorflow as tf
5 import matplotlib.pyplot as plt

~/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/init.py in
138 from . import _distributor_init
139
--> 140 from . import core
141 from .core import *
142 from . import compat

~/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/init.py in
46 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
47 version, exc)
---> 48 raise ImportError(msg)
49 finally:
50 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.8 from "/Users/floydjaggy/Desktop/RNA_fold/env/bin/python"
  • The NumPy version is: "1.19.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen(/Users/floydjaggy/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 0x0002): Library not loaded: @rpath/libcblas.3.dylib
Referenced from: /Users/floydjaggy/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so
Reason: tried: '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/python3.8/site-packages/numpy/core/../../../../libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/bin/../lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/lib/libcblas.3.dylib' (no such file), '/Users/floydjaggy/Desktop/RNA_fold/env/bin/../lib/libcblas.3.dylib' (no such file), '/usr/local/lib/libcblas.3.dylib' (no such file), '/usr/lib/libcblas.3.dylib' (no such file)

i installed numpy in the virtual environment using the given command of
conda install jupyter pandas numpy matplotlib scikit-learn

any help is much appreciated

@KrishnenduDakshi2002
Copy link

I faced the same issue-
hope it will help you

reason - 1:
"miniforge3" and "tensorflow-test" both have to be in same directory, if you try to create this "tensor flow-test" dir anywhere else, when you try to install packages using Conda install it will face error(look carefully at the end of command execution), meaning , no packages are successfully installed, that's why when you import those libraries error occurs.

sol- remove "miniforge3" and reinstalling it and just kept "miniforge3" and "tensor flow-test" in same directory

reason -2:
You maybe trying to run it on different python kernel

you can add another step , by this you can run any of your notebook one this env

Installing ipykernel and adding new ipykernel

pip install ipykernel
python3 -m ipykernel install --user --name=<any_name>

**Uninstalling any unwanted ipykernel **

to get path of installed kernels

jupyter kernelspec list

for uninstalling

jupyter kernelspec uninstall unwanted-kernel_name

Writing this comment on the basis of my observations and experience while installing, I am not an expert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants