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

Home Brew or python.org Python does not work on Mac, apt-get python3 does not work on linux & windows store Python too does not work #12808

Closed
DonJayamanne opened this issue Feb 10, 2023 · 4 comments · Fixed by #12813, #12819 or #12822
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verification-steps-needed Steps to verify are needed for verification
Milestone

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Feb 10, 2023

Tested the following scenarios:

    1. HomeBrew Python on Mac
    1. Python install from Python org on Mac
    1. apt-get install python3 on Ubuntu
    1. Windows Store Python on Windows

In all of these cases when we install packages a warning is displayed in the terminal indicating the fact that packages are being installed in a directory that is not on the PATH.
Upon further investigation it is found that this directory is a USER_SITE directory.

After all, when we install packages into the global envs we use the --user flag.
Which results in installing the packages in a user directory (hence USER_SITE).

The work around here is to ensure we add that path into the PATH
This service merely returns the path that needs to be added to the PATH.

Problem

When zmq does not work, then starting jupyter using a global python env fails.
As a result kernel startup fails.

Why don't we see this today for most users

zmq makes it unnecessary to start Jupyter using global python envs
Jupyter executables are stored in the directory that is not in the current path (warning above) as a result, jupyter cannot be located by the packages.

Solution

  • Ensure path is added as per the warning message

Here is the installation output for python3 -m jupyter notebook --user when running from the terminal

Notice the message

  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script jupyter-events is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Based on the docs on Home Brew we need to add the path, and this is documented on their site too
https://docs.brew.sh/Homebrew-and-Python

site-packages and the PYTHONPATH
The site-packages is a directory that contains Python modules, including bindings installed by other formulae. Homebrew creates it here:

$(brew --prefix)/lib/pythonX.Y/site-packages
So, for Python 3.y.z, you’ll find it at /usr/local/lib/python3.y/site-packages.

Python 3.y also searches for modules in:

/Library/Python/3.y/site-packages
~/Library/Python/3.y/lib/python/site-packages
Homebrew’s site-packages directory is first created (1) once any Homebrew formulae with Python bindings are installed, or (2) upon brew install python.
ollecting arrow>=0.15.0
  Using cached arrow-1.2.3-py3-none-any.whl (66 kB)
Installing collected packages: webencodings, wcwidth, Send2Trash, pure-eval, ptyprocess, pickleshare, mistune, ipython-genutils, fastjsonschema, executing, backcall, appnope, widgetsnbextension, websocket-client, webcolors, uri-template, traitlets, tornado, tinycss2, soupsieve, sniffio, rfc3986-validator, rfc3339-validator, pyzmq, pyyaml, python-json-logger, python-dateutil, pyrsistent, pygments, pycparser, psutil, prompt-toolkit, prometheus-client, platformdirs, pexpect, parso, pandocfilters, packaging, nest-asyncio, markupsafe, jupyterlab-widgets, jupyterlab-pygments, jsonpointer, idna, fqdn, defusedxml, decorator, debugpy, bleach, attrs, asttokens, terminado, stack-data, qtpy, matplotlib-inline, jupyter-core, jsonschema, jinja2, jedi, comm, cffi, beautifulsoup4, arrow, anyio, nbformat, jupyter-server-terminals, jupyter-client, isoduration, ipython, argon2-cffi-bindings, nbclient, ipykernel, argon2-cffi, qtconsole, nbconvert, jupyter-events, jupyter-console, ipywidgets, jupyter-server, notebook-shim, nbclassic, notebook, jupyter
  WARNING: The script send2trash is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script wsdump is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script pygmentize is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script qtpy is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The scripts jupyter, jupyter-migrate and jupyter-troubleshoot are installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script jsonschema is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script jupyter-trust is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The scripts jupyter-kernel, jupyter-kernelspec and jupyter-run are installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The scripts ipython and ipython3 are installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script jupyter-execute is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The scripts jupyter-dejavu and jupyter-nbconvert are installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script jupyter-events is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script jupyter-console is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The script jupyter-server is installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The scripts jupyter-nbclassic, jupyter-nbclassic-bundlerextension, jupyter-nbclassic-extension and jupyter-nbclassic-serverextension are installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
  WARNING: The scripts jupyter-bundlerextension, jupyter-nbextension, jupyter-notebook and jupyter-serverextension are installed in '/Users/donjayamanne/Library/Python/3.10/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug notebook-kernel-startup labels Feb 10, 2023
@DonJayamanne DonJayamanne added this to the February 2023 milestone Feb 10, 2023
@DonJayamanne DonJayamanne self-assigned this Feb 10, 2023
@DonJayamanne DonJayamanne changed the title Home Brew Python does not work on Mac (probably linux as well) Home Brew Python does not work on Mac and apt-get python3 does not work on linux Feb 10, 2023
@DonJayamanne
Copy link
Contributor Author

Similar output from linux as well
python3 -m pip install jupyter notebook --user

& here is the output

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script jupyter-execute is installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts ipython and ipython3 are installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts jupyter-dejavu and jupyter-nbconvert are installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script jupyter-events is installed in '/root/.local/bin' which is not on PATH.

@DonJayamanne DonJayamanne changed the title Home Brew Python does not work on Mac and apt-get python3 does not work on linux Home Brew or python.org Python does not work on Mac, apt-get python3 does not work on linux Feb 12, 2023
@DonJayamanne
Copy link
Contributor Author

Even using Python org python install on Mac fails, we need to setup the same path for Mac

Found that the path that needs to be setup is USER_BASE/(bin|Scripts)
Where USER_BASE can be retrieved from import site;site.USER_BASE

@DonJayamanne DonJayamanne reopened this Feb 12, 2023
@DonJayamanne
Copy link
Contributor Author

Same problem with Windows store Python

@DonJayamanne DonJayamanne changed the title Home Brew or python.org Python does not work on Mac, apt-get python3 does not work on linux Home Brew or python.org Python does not work on Mac, apt-get python3 does not work on linux & windows store does not work on Windows Feb 12, 2023
@DonJayamanne DonJayamanne changed the title Home Brew or python.org Python does not work on Mac, apt-get python3 does not work on linux & windows store does not work on Windows Home Brew or python.org Python does not work on Mac, apt-get python3 does not work on linux & windows store Python too does not work Feb 12, 2023
@karrtikr karrtikr added the verification-steps-needed Steps to verify are needed for verification label Feb 23, 2023
@karrtikr
Copy link
Contributor

Could you add the steps to verify the fix?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verification-steps-needed Steps to verify are needed for verification
Projects
None yet
2 participants