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.

Unable to pair to a py script in the same directory

See original GitHub issue

I have this project.toml file and everything works just fine:

[tool.jupytext.formats]
"notebooks/" = "ipynb"
"src/" = "py"
"md/" = "md"

Now, I want to pair a notebook to a py script in the same directory as the notebook, so following the docs, I modified the toml file to:

[tool.jupytext.formats]
"notebooks/" = "ipynb,py"
"src/" = "py"
"md/" = "md"

and suddenly nothing works. I get the following error:

Unexpected error while saving file: notebooks/Untitled.ipynb 
Notebook base name 'src/Untitled' is not compatible with fmt=notebooks///ipynb. Make sure you use prefix roots in either none, or all of the paired formats

Although it does silently create Untitled.py and Untitled.md at respective directories after throwing this error, it does NOT create a py script in the notebooks directory.

So how can a sync a notebook to a py script in the same directory as the notebook without throwing errors?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mwoutscommented, Mar 22, 2022

I see (that seems to be a reasonable limitation of the TOML format).

Could you try the compressed form, then?

[tool.jupytext]
formats = "notebooks///ipynb,notebooks///py:percent,src///py:percent,md///md"
0reactions
mwoutscommented, Mar 29, 2022

You’re welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to import module in same directory when using pytest
It appears that import statements are relative to the directory you are currently in. The solution to calling another script in the same...
Read more >
Understanding Python imports, __init__.py and pythonpath
The current directory being the one where the script being run resides. This is the reason importing is fairly straightforward when both the ......
Read more >
Python on Windows FAQ — Python 3.11.1 documentation
How do I make an executable from a Python script? Is a *.pyd file the same as a DLL? How can I embed...
Read more >
How to import local modules with Python - Quentin Fortier
c import d would go 2 directories up, for example. 2nd solution: run as a module. It is unfortunate that scripts can't use...
Read more >
Debugging configurations for Python apps in Visual Studio Code
Run VS Code, open the folder or workspace containing the script, and create a launch.json for that workspace if one doesn't exist already....
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