0

It seems that I have several version of python installed on same computer, one from them being the anaconda distribution. However certain packages can be imported only with certain version of python. How can we merge all the source of packages:

I succesfully installed opencv and try to import it in a script from Atom with the command import cv2 (1):

ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/cv2.so, 2): Library not loaded: /usr/local/opt/ilmbase/lib/libImath-2_2.12.dylib
  Referenced from: /usr/local/Cellar/opencv/3.4.1_4/lib/libopencv_imgcodecs.3.4.dylib
  Reason: image not found

Importing with command python (the one linked to anaconda)

I went then to the Terminal and called python with $ python

Python 3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 13undefined09) 
GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53) on darwin

I then tried to import open cv with import cv2 and got the same error message as in (1) above

Importing with command python3

I then entered import python3 (instead of python), it worked: I got:

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03undefined55) GCC 4.2.1 (Apple 
Inc. build 5666) (dot 3) on darwin

And could execute a script with import cv2

apparently those 2 different command fetch the package from different locations because:$ which python get me /anaconda3/bin/python and $ which python3 gets me /Library/Frameworks/Python.framework/Versions/3.6/bin/python3

As I use Atom as text editor, how can I make Atom to look at the correct place?

Many thanks in advance!

Specifications:

  • macOS 10.14
  • Python 3.6.5
ecjb
  • 5,169
  • 12
  • 43
  • 79

1 Answers1

0

Ok, I had actually to change the Path in the .json file of the jupyter kernel. First I checked the list of jupyter kernel:

$ jupyter kernelspec list
julia-0.6    /Users/mymac/Library/Jupyter/kernels/julia-0.6
julia-1.0    /Users/mymac/Library/Jupyter/kernels/julia-1.0
python3      /Users/mymac/Library/Jupyter/kernels/python3

I then cd the above python path and, I found the file kernel.json inside and opened it:

{
 "argv": [
  "/path/to/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

In that file, I then changed the line /path/to/python by the python path I got when typing the following in Terminal:

$ which python
/Users/mymac/anaconda3/bin/python

Relaunched Atom and it finally worked!

The hints of the github page of jupyter helped also a lot!

ecjb
  • 5,169
  • 12
  • 43
  • 79