hchauvet / beampy

Beampy is a python tool to create slide-show in svg that can be displayed in web browser or pdf
https://hchauvet.github.io/beampy
GNU General Public License v3.0
58 stars 18 forks source link

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/ipykernel_9763/3412949252.py' #37

Closed chaffra closed 1 year ago

chaffra commented 1 year ago

Running from jupyter notebook on WSL. doc = document() returns

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In [2], line 1
----> 1 doc = document()

File ~/python3/src/beampy/beampy/document.py:247, in document.__init__(self, quiet, latex_packages, source_filename, **kwargs)
    244 self.link_external_programs()
    246 # Load the source code of the current presentation
--> 247 self.get_source_code(source_filename)
    250 # Output the storage of slide etc... in debug logger
    251 _log.debug('Document class before adding slides')

File ~/python3/src/beampy/beampy/document.py:382, in document.get_source_code(self, sourcefilename)
    381 def get_source_code(self, sourcefilename=None):
--> 382     document._source_code = SourceManager(sourcefilename)

File ~/python3/src/beampy/beampy/document.py:101, in SourceManager.__init__(self, filename)
     99 # Is the script launch from python ./my_file.py
    100 if '.py' in guess_filename:
--> 101     with open(guess_filename, 'r') as f:
    102         self.python_code = f.readlines()
    103     self.source = self.return_filesource

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/ipykernel_9763/3412949252.py'
chaffra commented 1 year ago

Work fine when running from python script.

hchauvet commented 1 year ago

Hi Chaffra,

The version in the master branch is not compatible with Jupyter notebook. The version in the dev branch has a trick to work with jupyter notebook, you just have to add a slide_num to slide object (but the dev branch is not yet ready for daily use, some component are still missing).

Here is the trick with the dev branch in a jupyter notebook

with slide('test in jupyter', slide_num=0):
    text('this only work on the dev branch')
with slide('test in of a second slide', slide_num=1):
    text('this only work on the dev branch')