question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

path.sep goes missing when importing in a debugger in Python 3.10

See original GitHub issue

Hi,

I think I’m encountering the same error as https://github.com/pyproj4/pyproj/issues/1028 but with Fiona instead of pyproj

Also related: https://github.com/pytest-dev/pytest/issues/9791#issuecomment-1081617058

Expected behavior and actual behavior.

The following code should run without any error:

import os
print(os.path.sep)
import fiona
print(os.path.sep)

But, I get the following exception:

/Users/idan.miara/.pyenv/versions/py310/bin/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client 127.0.0.1 --port 49298 --file /Users/idan.miara/workspace/temp/temp.py 
/
Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1496, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/idan.miara/workspace/temp/temp.py", line 4, in <module>
    print(os.path.sep)
AttributeError: module 'posixpath' has no attribute 'sep'```

Steps to reproduce the problem.

Run the code snippet above in Python 3.10 in debug mode (I use PyCharm)

The problem is reproducible on: Python 3.10.7 in debug mode

The problem is not reproducible on: Python 3.10.7 in non-debug mode (normal run) Python 3.9.12 in either mode

Operating system

For example: Mac OS X 12.6

Fiona and GDAL version and provenance

Fiona 1.8.21 installed from PyPI using pip version 22.2.2.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sgilliescommented, Oct 25, 2022

Done!

0reactions
idanmiaracommented, Oct 3, 2022

I’m not familiar with Python’s development mode, but when I run any pytest test in PyCharm with Python 3.10, that imports fiona, it fails with that error.

I did find a workaround, adding the following code at the top of the test makes the test pass:

import os.path
sep = os.path.sep
import fiona
os.path.sep = sep

On Mon, 3 Oct 2022, 23:41 Sean Gillies, @.***> wrote:

@idanmiara https://github.com/idanmiara I think a 1.8.22 release is appropriate. It’s only the use of Python’s development mode that is prevented, no? Or is a future version of pytest switching to requiring development mode?

— Reply to this email directly, view it on GitHub https://github.com/Toblerity/Fiona/issues/1143#issuecomment-1266023202, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGJBBLNWSHE4C4DS2WNQ3QTWBNAJLANCNFSM6AAAAAAQ25YPNM . You are receiving this because you were mentioned.Message ID: @.***>

Read more comments on GitHub >

github_iconTop Results From Across the Web

in VS Code ImportError: cannot import name 'Mapping' from ...
4. I think the problem is inside the test.py: from collections import Mapping · 7. Problem solved by: from collections. · 2. It...
Read more >
What's New In Python 3.10 — Python 3.11.1 documentation
PEP 626, Precise line numbers for debugging and other tools. ... but in Python 3.10 a more informative error is emitted: ... Missing...
Read more >
How to use the Python debugger (pdb) - Red Hat
Pdb is a powerful tool for finding syntax errors, spelling mistakes, missing code, and other issues in your Python code.
Read more >
Python debugger not working while normal run does
The python debugger in Pycharm (I've the latest version) is not working for ... This way import termios in getpass will correctly fail...
Read more >
ModuleNotFoundError: no module named Python Error [Fixed]
you are importing a module using the wrong path. How to fix the ModuleNotFoundError in Python. As I mentioned in the previous section,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found