简体   繁体   中英

ImportError when debugging but not when running in PyCharm

I am building a desktop app using the python library Kivy. Since I installed a plugin to be able to visualize.kv files, I am not able to debug my code. Yet I am able to run it without problems. This is the error I keep getting:

 Traceback (most recent call last):
   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
   File "...\Worktime_Tool\venv\lib\site-packages\kivy\app.py", line 416, in <module>
     from os.path import dirname, join, exists, sep, expanduser, isfile
 ImportError: cannot import name 'sep' from 'ntpath' (...\AppData\Local\Programs\Python\Python310\lib\ntpath.py)

So far I do not understand where this ntpath stands for. I tried to compare the ntpath while debugging and while running and they are the same. I also double checked that the interpreter set for the prrject and the interpreter in the run/debug configurations are the same.

I tried with and without the usage of a venv .

Does anyone have an idea why I can run this app but not debug it?

Appreciate much the help!

I had the same problem a while ago. You can either edit the \lib\site-packages\kivy\app.py in your virtual environment to remove the sep from that import line on line 416.

It will look like this after you remove the sep.

from os.path import dirname, join, exists, expanduser, isfile

Or

Update to the latest version of kivy which no longer gives me the error.

You can update to the latest kivy developer build with this command:

python -m pip install "kivy[base] @ https://github.com/kivy/kivy/archive/master.zip"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM