λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
IT-Engineering/TroubleShooting

importError: DLL load failed while importing win32api: μ§€μ •λœ λͺ¨λ“ˆμ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€. μ—λŸ¬ ν•΄κ²° ν•˜κΈ°

by 🧞‍♂️ 2021. 2. 18.
λ°˜μ‘ν˜•

Anaconda3 64λΉ„νŠΈ ν™˜κ²½μ—μ„œ Jupyter Lab을 μ‹€ν–‰ν•˜λ €λ‹€ λ°œμƒν•œ μ—λŸ¬μ΄λ‹€. λ§Žμ€ κ³³μ—μ„œλŠ” μ•„λž˜μ™€ 같은 해결책을 λ§ν•˜κ³  μžˆμœΌλ‚˜ ν•„μžμ—κ²ŒλŠ” 도움이 λ˜μ§€ μ•Šμ•˜λ‹€. (훼이크 주의!)

pip uninstall pypiwin32 
pip install pywin32

μ‹€μ œ μ½”λ“œλ₯Ό μ°Ύμ•„λ“€μ–΄κ°€ 보면 μ΄λ ‡κ²Œ 생겼닀. μ•„λ‚˜μ½˜λ‹€ 64bit ν™˜κ²½μ—μ„œ μ‹€ν–‰ν•  λ•Œ 이 μ½”λ“œμ˜ import win32api μ—μ„œ μ—λŸ¬κ°€ λ°œμƒν•œ 것이닀.

{anaconda3경둜}\envs\{ν™˜κ²½μ΄λ¦„}\lib\site-packages\jupyter_core\paths.py
def win32_restrict_file_to_user(fname):
    """Secure a windows file to read-only access for the user.
    Follows guidance from win32 library creator:
    http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html

    This method should be executed against an already generated file which
    has no secrets written to it yet.

    Parameters
    ----------

    fname : unicode
        The path to the file to secure
    """
    import win32api
    import win32security
    import ntsecuritycon as con

μ—λŸ¬μ˜ κ°€μž₯ μ€‘μš”ν•œ λ‚΄μš©μ€ 이 뢀뢄이고.

  File "c:\anaconda3\envs\trader\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed while importing win32api: μ§€μ •λœ λͺ¨λ“ˆμ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€.

μ—λŸ¬ λ‚΄μš©μ˜ 전문은 μ•„λž˜μ™€ κ°™λ‹€.

Traceback (most recent call last):
  File "c:\anaconda3\envs\trader\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\anaconda3\envs\trader\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Anaconda3\envs\trader\Scripts\jupyter-lab.EXE\__main__.py", line 7, in <module>
  File "c:\anaconda3\envs\trader\lib\site-packages\jupyter_server\extension\application.py", line 517, in launch_instance
    serverapp.start()
  File "c:\anaconda3\envs\trader\lib\site-packages\jupyter_server\serverapp.py", line 2012, in start
    self.start_app()
  File "c:\anaconda3\envs\trader\lib\site-packages\jupyter_server\serverapp.py", line 1972, in start_app
    self.write_server_info_file()
  File "c:\anaconda3\envs\trader\lib\site-packages\jupyter_server\serverapp.py", line 1862, in write_server_info_file
    with secure_write(self.info_file) as f:
  File "c:\anaconda3\envs\trader\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "c:\anaconda3\envs\trader\lib\site-packages\jupyter_core\paths.py", line 461, in secure_write
    win32_restrict_file_to_user(fname)
  File "c:\anaconda3\envs\trader\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed while importing win32api: μ§€μ •λœ λͺ¨λ“ˆμ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€.

 

"이제 κ°€μž₯ μ€‘μš”ν•œ ν•΄κ²° 방법 λ‚˜κ°„λ‹€."

 

 λ¬Έμ œ ν•΄κ²° 방법

conda λͺ…λ Ήμ–΄λ₯Ό 톡해 pywin32λ₯Ό μ„€μΉ˜ν•΄μ£Όμž.

conda install -c anaconda pywin32

μ΄ν›„λ‘œ jupyter lab λͺ…령은 이제 λ‹€μ‹œ 잘 λ™μž‘ν•˜κ³  μžˆλ‹€. λˆ„κ΅°κ°€ λΉ„μŠ·ν•œ 문제λ₯Ό κ²ͺλŠ”λ‹€λ©΄ 도움이 λ˜μ—ˆκΈ°λ₯Ό λ°”λž€λ‹€.

 

 

λ°˜μ‘ν˜•

λŒ“κΈ€