Search code examples
python-3.xjupyterjupyter-labminiconda

Unable to launch Jupyter lab from cmd in windows 7


The command 'jupyter lab' usually works fine in cmd. But today it isn't. I uninstall and reinstalled all jupyter components but no gain. Jupyter notebook seems to be working though.

C:\Users\Sarth.choudhary>jupyter lab Cannot open D:\Programs\Miniconda3\Scripts\jupyter-lab-script.py

I looked into the miniconda directory, jupyter-lab-script.py is indeed missing. I don't have this file anywhere in the miniconda directory.

Any help much appreciated.


Solution

  • The missing my-env/Scripts/jupyter-lab-script.py is just a very simple launch script for the jupyterlab.labapp.main function.

    So just create my-env/Scripts/jupyter-lab-script.py containing the following code and the problem is solved (no need to create a whole new environment to copy from):

    # -*- coding: utf-8 -*-
    import re
    import sys
    
    from jupyterlab.labapp import main
    
    if __name__ == '__main__':
        sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
        sys.exit(main())
    

    (NOTE: I copy-pasted from my-env/Scripts/jupyter-notebook-script.py and replaced the imported module by the correct jupyterlab.labapp. Didn't check if that is exactly the same as the original, but it works the same.)