Issue with Docker storage - Cannot instantiate 'WindowsPath' on your system
See original GitHub issueOpened from the Prefect Public Slack Community
arthur: Hi, my first message here 🙂. I am new to Prefect, and I was able to run my flow from my local PC (Windows, python 3.8). Now I am trying to build it to a Docker Storage, and I am getting this error during the health check:
raise NotImplementedError("cannot instantiate %r on your system" NotImplementedError: cannot instantiate 'WindowsPath' on your system
Any ideas?
arthur: full error message is here:
Step 14/14 : RUN python /opt/prefect/healthcheck.py '["/opt/prefect/flows/project01-reports.prefect"]' '(3, 8)'
---> Running in 52f09f649e73
Beginning health checks...
System Version check: OK
Traceback (most recent call last):
File "/opt/prefect/healthcheck.py", line 147, in <module>
flows = cloudpickle_deserialization_check(flow_file_paths)
File "/opt/prefect/healthcheck.py", line 40, in cloudpickle_deserialization_check
flows.append(cloudpickle.load(f))
File "/usr/local/lib/python3.8/pathlib.py", line 1043, in __new__
raise NotImplementedError("cannot instantiate %r on your system"
NotImplementedError: cannot instantiate 'WindowsPath' on your system
Removing intermediate container 52f09f649e73
The command '/bin/sh -c python /opt/prefect/healthcheck.py '["/opt/prefect/flows/project01-reports.prefect"]' '(3, 8)'' returned a non-zero code: 1
Traceback (most recent call last):
File "flows/project01/project01_flow.py", line 400, in <module>
my_flow.register("project01")
File "D:\Programas\py_temp\prefect\lib\site-packages\prefect\core\flow.py", line 1620, in register
registered_flow = client.register(
File "D:\Programas\py_temp\prefect\lib\site-packages\prefect\client\client.py", line 734, in register
serialized_flow = flow.serialize(build=build) # type: Any
File "D:\Programas\py_temp\prefect\lib\site-packages\prefect\core\flow.py", line 1458, in serialize
storage = self.storage.build() # type: Optional[Storage]
File "D:\Programas\py_temp\prefect\lib\site-packages\prefect\environments\storage\docker.py", line 351, in build
self._build_image(push=push)
File "D:\Programas\py_temp\prefect\lib\site-packages\prefect\environments\storage\docker.py", line 417, in _build_image
raise ValueError(
ValueError: Your docker image failed to build! Your flow might have failed one of its deployment health checks - please ensure that all necessary files and dependencies have been included.
znicholasbrown: Hi <@U01DENWR97F>, welcome! 👋
znicholasbrown: This sounds like it’s related to the way Core is pickling your flow as it’s trying to build - I’m going to open an issue on the Core repo because they’ll be better able to triage this.
znicholasbrown: <@ULVA73B9P> open “Issue with Docker storage - Cannot instantiate ‘WindowsPath’ on your system”
Original thread can be found here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Pickle load error: cannot instantiate 'WindowsPath' on your ...
I ran a python program on Windows 10 which generated a .p file with ... raise NotImplementedError("cannot instantiate %r on your system" ...
Read more >Troubleshoot topics | Docker Documentation
If you try to run a Linux container on the native Docker daemon, an error occurs: C:\Program Files\Docker\docker.exe: image operating system "linux" cannot...
Read more >Python 3's pathlib Module: Taming the File System
The Problem With Python File Path Handling; Creating Paths ... WindowsPath('test.md') NotImplementedError: cannot instantiate 'WindowsPath' on your system.
Read more >10 things to avoid in docker containers | Red Hat Developer
For that reason, if you need to store data, do it in a volume. ... your application can't run because a parent layer...
Read more >Changelog — Python 3.11.1 documentation
gh-99729: Fix an issue that could cause frames to be visible to Python code ... Prevent this by adding runtime support for detection...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, thanks for your feedback. I gave up on Windows and decided to install WSL2 with a Ubuntu distro on my Windows 10, then I could finally register Prefect without problems using the Pathlib python lib.
@arthur-datalab I believe this problem is arising because
pathlib.Path
objects are not serializable (pickleable) between systems (in your case, Windows <-> Linux). A few things you might try:stored_as_script=True
on yourDocker
storage object; this will prevent the serialization of thePath
objectpathlib.Path