글 작성자: 만렙개발자
import numpy as np
from google.colab import drive
drive.mount('/content/drive',force_remount=True)
%cd "/content/drive/My Drive/"

이런식으로 force_remount를 했으나, 아래와 같은 장문의 에러가 발생했다.

ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

Mounted at /content/drive
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2882, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-19-7add2dbb7e59>", line 4, in <module>
    get_ipython().magic('cd "/content/drive/My Drive/0_colab/FinML/"')
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2160, in magic
    return self.run_line_magic(magic_name, magic_arg_s)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 2081, in run_line_magic
    result = fn(*args,**kwargs)
  File "</usr/local/lib/python3.6/dist-packages/decorator.py:decorator-gen-91>", line 2, in cd
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/magic.py", line 188, in <lambda>
    call = lambda f, *a, **k: f(*a, **k)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/magics/osm.py", line 288, in cd
    oldcwd = py3compat.getcwd()
OSError: [Errno 107] Transport endpoint is not connected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py", line 1823, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'OSError' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/ultratb.py", line 1132, in get_records
    return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/ultratb.py", line 313, in wrapped
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/ultratb.py", line 358, in _fixed_getinnerframes
    records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
  File "/usr/lib/python3.6/inspect.py", line 1490, in getinnerframes
    frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
  File "/usr/lib/python3.6/inspect.py", line 1448, in getframeinfo
    filename = getsourcefile(frame) or getfile(frame)
  File "/usr/lib/python3.6/inspect.py", line 696, in getsourcefile
    if getattr(getmodule(object, filename), '__loader__', None) is not None:
  File "/usr/lib/python3.6/inspect.py", line 725, in getmodule
    file = getabsfile(object, _filename)
  File "/usr/lib/python3.6/inspect.py", line 709, in getabsfile
    return os.path.normcase(os.path.abspath(_filename))
  File "/usr/lib/python3.6/posixpath.py", line 383, in abspath
    cwd = os.getcwd()
OSError: [Errno 107] Transport endpoint is not connected
---------------------------------------------------------------------------

[Errno 107] Transport endpoint is not connected 에러를 해결하는 방법들을 찾아보았다.

 

 

1. unmount하고 mount를 다시하는 방식이다.

 

!fusermount -u drive

!google-drive-ocamlfuse drive

 

ref: https://stackoverflow.com/questions/49588113/google-colab-script-throws-transport-endpoint-is-not-connected

 

하지만, 경우에 따라 아래와 같이 여전히 endpoint 문제로 에러가 발생할 수 있다.

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Transport endpoint is not connected
fusermount: bad mount point drive: Transport endpoint is not connected
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Transport endpoint is not connected
/bin/bash: google-drive-ocamlfuse: command not found

 

2. drive timeout 문제

 

드라이브의 루트 Directory (/ content / gdrive / My Drive)에 많은 파일이 있는게 문제라고 합니다.

물론.. 파일이 많긴 한데...;; ㅠㅠ 

 

ref: https://github.com/googlecolab/colabtools/issues/284

ref: https://research.google.com/colaboratory/faq.html#drive-timeout

 

루트 폴더 정리하기 or

그냥 런타임 초기화, drive mount authorization 다시 하기

 

저는 런타임 초기화 하고 drive mount authorization 다시 했더니 됩니다...

timeout이 자주 생기지 않기를 ... ㅠ