Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RunTimeError: weakly_canonical... when importing PDAL in standalone python script. #145

Open
nein25 opened this issue Mar 20, 2023 · 13 comments

Comments

@nein25
Copy link

nein25 commented Mar 20, 2023

I've installed PDAL using miniconda via "conda install -c conda-forge pdal python-pdal gdal". I was able to use PDAL in conda prompt successfully. When trying to run a standalone script in either PyCharm or Spyder, I receive the following error message:

E:\dev\tiff_to_las\data>"C:\Users\alex\AppData\Local\miniconda3\envs\pdalpython\python.exe" "E:\dev\tiff_to_las\pdal_tiff_to_las.py"
Traceback (most recent call last):
File "E:\dev\tiff_to_las\pdal_tiff_to_las.py", line 8, in
import pdal
File "C:\Users\alex\AppData\Local\miniconda3\envs\pdalpython\Lib\site-packages\pdal_init_.py", line 8, in
inject_pdal_drivers()
File "C:\Users\alex\AppData\Local\miniconda3\envs\pdalpython\Lib\site-packages\pdal\drivers.py", line 66, in inject_pdal_drivers
drivers = libpdalpython.getDrivers()
^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: weakly_canonical: The device is not ready.: "D:/bld/pdal_1678484181627/_h_env/Library/bin"

E:\dev\tiff_to_las\data>pause
Press any key to continue . . .

My machine has a D:/, but it's a DVD RW Drive that is never used. I have tried removing OSGeo4W, which had PDAL. I have tried removing and recreating the PDAL environment in miniconda, and the error persists. Apologies if this is a duplicate, I did a bit of searching to find a similar issue and wasn't able to find any. Thanks a bunch for any help.

@hobu
Copy link
Member

hobu commented Mar 20, 2023

I believe "D:/bld/pdal_1678484181627/_h_env/Library/bin" is the path that is used on the @conda-forge builder.

What does conda list show for you?

@nein25
Copy link
Author

nein25 commented Mar 20, 2023

Strange... the channel listed beside pdal is pypi, not conda-forge.

image

@hobu
Copy link
Member

hobu commented Mar 20, 2023

please try installing from python-pdal and see if you still have issues.

Even so, I do not understand where this error is coming from.

@nein25
Copy link
Author

nein25 commented Mar 20, 2023

Could you clarify 'installing from python-pdal' please? Thank you

@hobu
Copy link
Member

hobu commented Mar 20, 2023

conda install -c conda-forge python-pdal instead of pip install PDAL. Do this in a fresh environment.

@nein25
Copy link
Author

nein25 commented Mar 20, 2023

It still lists pypi as the channel beside PDAL. I did create a new environment for testing.
image

image

This may not be pertinent, but it's very likely I downloaded PDAL via PIP a year or more ago before I knew anything about Conda.

@hobu
Copy link
Member

hobu commented Mar 20, 2023

It still lists pypi as the channel beside PDAL

confirmed I'm seeing this on a fresh environment too. I do not get the weakly_canonical error when I import pdal however

@hobu
Copy link
Member

hobu commented Mar 20, 2023

I think the issue is conda is confused:

  • pdal is the name of the base PDAL library/utilities
  • python-pdal is the name of the PDAL Python extension for Conda
  • PDAL is the name of the PDAL Python extension on PyPI

I'm not quite sure what to do here. Any ideas @chambbj ?

@nein25
Copy link
Author

nein25 commented Mar 20, 2023

I just tried a couple of things, maybe helpful to know - maybe not!

In the Conda prompt, for both my fresh test environment (pdal_test), and the existing one (pdalpython) - I am able to import pdal without issue. When I open Spyder via conda prompt for the pdalpython environment, and import pdal through the console, I get the error message. This is also true with PyCharm and VSCode. Perhaps an issue with my IDE settings?

image

image

image

@hobu
Copy link
Member

hobu commented Mar 20, 2023

there have been a number of tickets related to Spyder.

The path that is being checked there must be related to not having a PDAL_DRIVER_PATH environment variable set.

Try setting PDAL_DRIVER_PATH=%CONDA_PREFIX\Library\bin in your Spyder environment and see if the import succeeds.

@nein25
Copy link
Author

nein25 commented Mar 20, 2023

That did the trick! I was able to import pdal without issue in Spyder. Thanks so much for the help.

EDIT: I did figure out how to update the path in Spyder preferences.

image

@hobu
Copy link
Member

hobu commented Mar 20, 2023

The cause of the issue is PDAL_DRIVER_PATH is set by the Conda Forge recipe when PDAL is configured, and it is embedded as a default lookup directory into the DLL when it is built. In Conda's case, this is the DLL directory relevant to where/how it is being built as a package.

The straight Conda package activate/deactivate scripts take care of handling PDAL_DRIVER_PATH so we never see the error of it trying its default directory that doesn't exist (because it was set to the CONDA_PREFIX of the builder machine that compiled the package, not where it was deployed).

PDAL could certainly not try to list directories that don't exist, and that issue is PDAL/PDAL#4005

This rest of it is an issue that should be handled in the Conda package, but I'm not sure how to do it. https://github.com/conda-forge/python-pdal-feedstock/ is where the conda package is managed.

@WillhKessler
Copy link

Any updates on fixing this issue? I'm getting the same 'RuntimeError: weakly_canonical" error in a fresh Anaconda installation, python 3.11.1 and using a fresh environment? I've tried uninstalling and reinstalling everything multiple times without success.

I installed the python-pdal package with command conda install -c conda-forge python-pdal followed by conda update python-pdal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants