mercury icon indicating copy to clipboard operation
mercury copied to clipboard

Error during notebook initialization. argument of type 'WindowsPath' is not iterable.

Open pplonski opened this issue 3 years ago • 7 comments

From email from user:

When trying to “watch” a notebook, the following error occurs: Error during notebook initialization. argument of type 'WindowsPath' is not iterable.

Somewhere in the settings.py file (mercury). A string was expected, but a path was provided.

I cast all x / “y” to str(x / “y”) e.g. STATIC_ROOT = str(BASE_DIR / "static").

This seemed to fix the error.

pplonski avatar May 16 '22 16:05 pplonski

After running the demo.ipynb file (mercury run demo), and changing the sliders (e.g. year to 2030 -> run) on the left side I received the following error: "Notebook is executed with errors. unsupported operand type(s) for /: 'str' and 'str' ".

So, I started to remove to string casts to see which one(s) are necessary to prevent the "argument of type 'WindowsPath' is not iterable" error. The only necessary string cast is on line 225 in server.settings.py (MEDIA_ROOT = BASE_DIR / "media").

However, when I cast this to a string, I get the error mentioned above ("Notebook is executed with errors. unsupported operand type(s) for /: 'str' and 'str' ".) in demo.ipynb on the mercury local server when adjusting e.g. the year and re-running it.

The error I receive when not casting (MEDIA_ROOT = str(BASE_DIR / "media")) Traceback (when MEDIA_ROOT = BASE_DIR / "media"

image

Have to write an essay for University right now, so I'll look further into this later on today or tomorrow.

DatSplit avatar May 17 '22 09:05 DatSplit

@DatSplit thanks for details! What Python version are you using?

pplonski avatar May 17 '22 10:05 pplonski

In my virtual environment I'm using Python 3.7.3

DatSplit avatar May 17 '22 10:05 DatSplit

When I try to run the demo, this error occurs:

image

Does this have anything to do with the failed Run on Windows:

image

Kind Regards,

DatSplit avatar May 18 '22 11:05 DatSplit

@DatSplit please try to re-create virtualenv - according to this https://stackoverflow.com/questions/38132755/importerror-no-module-named-encodings and please check python paths https://stackoverflow.com/questions/42512817/fatal-python-error-on-windows-10-modulenotfounderror-no-module-named-encodings

I'm in process of creating automatic tests for windows but the action is not yet completed.

pplonski avatar May 18 '22 11:05 pplonski

That was indeed what was wrong (Should've mentioned those stackoverflow links as I found them myself already, apologies).

Going to continue and work on fixing the notebook error: "Notebook is executed with errors. unsupported operand type(s) for /: 'str' and 'str'"

DatSplit avatar May 19 '22 07:05 DatSplit

Update: The error still persist when using your demo code from: (https://mljar.com/blog/computer-vision-app-python-opencv-mercury/). So, it has to do with the change in the server.settings file that fixed the windowspath error.

DatSplit avatar May 19 '22 08:05 DatSplit

@DatSplit I would like to ask whether you have found the solution for this issue as I am facing it too? Thanks in advance.

HidayetZaimaga avatar Dec 07 '22 12:12 HidayetZaimaga

@aplonska, could you please test it on Windows OS? @HidayetZaimaga we will look into it.

pplonski avatar Dec 07 '22 13:12 pplonski

@HidayetZaimaga Unfortunately, I didn't find a solution.

DatSplit avatar Dec 07 '22 17:12 DatSplit

I converted all paths to strings in the Django settings file. This should fix the issue.

The new code will be released tomorrow. Please notice, that we released Mercury V2. You can install new version with:

pip install mercury

# or

conda install -c conda-forge mercury

New documentation is available at https://RunMercury.com

pplonski avatar Feb 15 '23 09:02 pplonski