Skip to content

pip -e installed mintpy.__file__ = None when there is a mintpy folder in current dir #882

@yunjunz

Description

@yunjunz

Description of the problem

For mintpy installed in the editable mode using pip, when there is a folder named mintpy in the current data directory, Python would misidentify the mintpy folder as the module location; and result in a TypeError while running, as shown in the example commands below. Any idea how to fix this?

This only happens when mintpy is installed via pip install -e option; while regular pip install and conda install versions work fine.

Full script that generated the error

(insar) yunjunz:~/data/test/FernandinaSenDT128/mintpy>$ python -c "import mintpy; print(mintpy.__file__, mintpy.__path__)"
(insar) yunjunz:~/data/test/FernandinaSenDT128>$ python -c "import mintpy; print(mintpy.__file__, mintpy.__path__)"
(insar) yunjunz:~/data/test/FernandinaSenDT128>$ view.py mintpy/velocity.h5 

Full error message

(insar) yunjunz:~/data/test/FernandinaSenDT128/mintpy>$ python -c "import mintpy; print(mintpy.__file__, mintpy.__path__)"
/Users/yunjunz/tools/MintPy/mintpy/__init__.py ['/Users/yunjunz/tools/MintPy/mintpy']

(insar) yunjunz:~/data/test/FernandinaSenDT128>$ python -c "import mintpy; print(mintpy.__file__, mintpy.__path__)"
None _NamespacePath(['/Users/yunjunz/data/test/FernandinaSenDT128/mintpy', '/Users/yunjunz/data/test/FernandinaSenDT128/mintpy'])

(insar) yunjunz:~/data/test/FernandinaSenDT128>$ view.py mintpy/velocity.h5 
Traceback (most recent call last):
  File "/Users/yunjunz/tools/miniconda3/envs/insar/bin/view.py", line 8, in <module>
    sys.exit(main())
  File "/Users/yunjunz/tools/MintPy/mintpy/cli/view.py", line 166, in main
    from mintpy.view import viewer
  File "/Users/yunjunz/tools/MintPy/mintpy/view.py", line 26, in <module>
    from mintpy.utils import plot as pp, ptime, readfile, utils as ut
  File "/Users/yunjunz/tools/MintPy/mintpy/utils/plot.py", line 22, in <module>
    from mintpy.objects.colors import ColormapExt
  File "/Users/yunjunz/tools/MintPy/mintpy/objects/colors.py", line 24, in <module>
    MINTPY_CPT_DIR = os.path.join(os.path.dirname(mintpy.__file__), 'data', 'colormaps')
  File "/Users/yunjunz/tools/miniconda3/envs/insar/lib/python3.8/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

System information

  • Operating system: macOS
  • Python environment: conda for dependencies, pip for mintpy
  • MintPy version: 1.4.1-29, date 2022-10-31

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions