Hi all. When I run the following .py file, it gives this import error. However, when I make a Jupyter notebook in the same folder and run “import utils”, there is no error at all. What is going on?
(fastai2) malcolm@PC-GPU:~/fastaiActive/film restore/siggraphasia2019_remastering$ python remaster.py --input 'kb960x540.avi' --mindim 540 --disable_colorization --gpu
Traceback (most recent call last):
File "remaster.py", line 26, in <module>
import utils
File "/home/malcolm/fastaiActive/film restore/siggraphasia2019_remastering/utils.py", line 2, in <module>
from skimage import color
File "/home/malcolm/anaconda3/envs/fastai2/lib/python3.7/site-packages/skimage/color/__init__.py", line 1, in <module>
from .colorconv import (convert_colorspace,
File "/home/malcolm/anaconda3/envs/fastai2/lib/python3.7/site-packages/skimage/color/colorconv.py", line 56, in <module>
from scipy import linalg
File "/home/malcolm/anaconda3/envs/fastai2/lib/python3.7/site-packages/scipy/__init__.py", line 155, in <module>
from . import fft
File "/home/malcolm/anaconda3/envs/fastai2/lib/python3.7/site-packages/scipy/fft/__init__.py", line 79, in <module>
from ._helper import next_fast_len
File "/home/malcolm/anaconda3/envs/fastai2/lib/python3.7/site-packages/scipy/fft/_helper.py", line 3, in <module>
from ._pocketfft import helper as _helper
File "/home/malcolm/anaconda3/envs/fastai2/lib/python3.7/site-packages/scipy/fft/_pocketfft/__init__.py", line 3, in <module>
from .basic import *
File "/home/malcolm/anaconda3/envs/fastai2/lib/python3.7/site-packages/scipy/fft/_pocketfft/basic.py", line 6, in <module>
from . import pypocketfft as pfft
ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /home/malcolm/anaconda3/envs/fastai2/lib/python3.7/site-packages/scipy/fft/_pocketfft/pypocketfft.cpython-37m-x86_64-linux-gnu.so)
It sounds like the python environment of your Jupyter Kernel is different from the environment used in the terminal. From your error message I can see that the fastai2 conda environment is used in your terminal /home/malcolm/anaconda3/envs/fastai2
Run this line in your notebook to see which environment the kernel is running.
import sys; sys.executable
In the terminal, you can see list conda environments in the terminal and activate the environment
So the fact that bash sees different packages and libraries than Jupyter remains a mystery. Maybe my fastai2 environment is corrupted? But to rebuild it in the hope that maybe, possibly it would solve the problem seems likely to be a waste of time.
Yijin: Thanks for the link. I followed up with a search for the error message and found dozens of different replies, mainly of the form…
Try
[list of arcane linux terminal commands]
It worked for me!
There is no explanation of what actually went wrong and why those commands would fix it. Perhaps I am now officially a curmudgeon, but it seems like trying to fix a car engine by dumping in a gas additive. I was afraid of breaking something even more by executing incomprehensible commands.
Thanks for your replies. If anyone can explain why Bash and Jupyter are seeing different packages, I would like to understand.
P.S. For anyone who may ever need to use a .py command (one that uses argparse) inside Jupyter, simply replace
Hi,
I am also searching for the best solution to the same issue. I had tried it but couldn’t resolve it. I am also learning Python online @CETPA. If anybody has the right answer please share.