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

FileNotFound -- Jupyter #53

Open
PABessero opened this issue Dec 7, 2020 · 9 comments
Open

FileNotFound -- Jupyter #53

PABessero opened this issue Dec 7, 2020 · 9 comments

Comments

@PABessero
Copy link

Sous Jupyter Notebook, impossible d'utiliser la cell magic %mocodo ou %%mocodo

%%mocodo
test : test
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-31-d1c73185e9b7> in <module>
----> 1 get_ipython().run_line_magic('mocodo', '')
      2 test : test

~/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2324                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2325             with self.builtin_trap:
-> 2326                 result = fn(*args, **kwargs)
   2327             return result
   2328 

<decorator-gen-126> in mocodo(self, line, cell)

~/.local/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~/.local/lib/python3.6/site-packages/mocodo_magic/mocodo_magic.py in mocodo(self, line, cell)
    103             pass
    104 
--> 105         if execute_command(options):
    106             if not display_diagrams():
    107                 if "--print_params" in options:

~/.local/lib/python3.6/site-packages/mocodo_magic/mocodo_magic.py in execute_command(options)
     44         def execute_command(options):
     45             global stdoutdata
---> 46             process = Popen(["mocodo"] + options, stdin=PIPE, stdout=PIPE, stderr=PIPE)
     47             stdoutdata, stderrdata = process.communicate()
     48             try:

/usr/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
    727                                 c2pread, c2pwrite,
    728                                 errread, errwrite,
--> 729                                 restore_signals, start_new_session)
    730         except:
    731             # Cleanup if the child failed starting.

/usr/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1362                         if errno_num == errno.ENOENT:
   1363                             err_msg += ': ' + repr(err_filename)
-> 1364                     raise child_exception_type(errno_num, err_msg, err_filename)
   1365                 raise child_exception_type(err_msg)
   1366 

FileNotFoundError: [Errno 2] No such file or directory: 'mocodo': 'mocodo'
@laowantong
Copy link
Owner

Oui, je crois qu'il y a un problème quelque part dans la logique au lancement. Mais quand des étudiants m'ont remonté ça, il suffisait de relancer pour régler le problème (le dossier était alors créé). C'est le même cas ?

@PABessero
Copy link
Author

Si c'est relancer le Kernel, ca a rien fait, mais le dossier mocodo_notebook est bien cree
image

@laowantong
Copy link
Owner

Pour mes étudiants, il suffisait de relancer la commande magique. Mais vous n'êtes pas dans le même cas apparemment.

@PABessero
Copy link
Author

il semblerait, apres je tourne sous un jupyterhub qui est en serveur distant, et j'ai installe mocodo magic avec !pip3 install mocodo_magic, je ne sais pas si c'etait la bonne methode

@laowantong
Copy link
Owner

Ah ok, je n'ai jamais utilisé JupyterHub. La commande d'installation devrait être la bonne, et mocodo a l'air bien installé. Vous avez la possibilité d'essayer en local ?

@PABessero
Copy link
Author

malheureusement pas avec ce PC, je tenterai ce weekend quand je recupererais une vrai machine

@jumel-lycee
Copy link

Je viens d'essayer en local, et j'ai le même souci.

@jumel-lycee
Copy link

Bon, alors, j'ai à peu près compris l'erreur chez moi : un souci d'environnement.
En effet, depuis Jupyter :

import os
os.getenv('PATH')

me renvoyait un chemin incomplet.
Après avoir creusé un peu, j'ai découvert qu'en lançant Jupyter avec l'Unit de systemd (--user), le chemin n'était pas passé.
Les commandes :

systemctl --user import-environment PATH
systemctl --user restart jupyter-notebook.service

m'ont permis d'obtenir ce qu'il fallait.

Je verrai au prochain redémarrage si l'option est pérenne ou non, la documentation de systemd étant tellement touffue …

@vincentxavier
Copy link

Bon, je confirme qu'il faut importer le PATH puis relancer l'environnement jupyter. Peut-être à rajouter dans la doc

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

No branches or pull requests

4 participants