[Caution] I don't think this article is useful if you are not working with root privileges. This issue is caused by working with root privileges, so general users do not need to read it. I think.
I usually develop on WSl, but I will explain the point that I got stuck when I tried to write Python for the first time in a while today.
I'm using pyenv for python version control. I'm also using pipenv to set up a virtual environment in the project directory. I try to install external modules via pipenv.
Prepare the virtual environment with the following command
mkdir py_playground && cd py_playground
pipenv --python 3.8
Pipfile(Node.package in js.Something like json)
Pipfile.lock
I always thought that I would launch vscode and write in Jupyter Notebook, and when I launched a new notebook ...
** Kernel does not connect **
It's funny, the virtual environment should be set up with pipenv ... So I embarked on a long, long journey to launch Jupyter
It worked when I was developing on windows ... what's the difference ...
The first thing I found was that the .venv directory that should contain the interpreter wasn't created.
This is because the virtual environment is created under ~ / .local / share / virtualenvs /
with the default settings of pipenv.
I decided to change this for the time being.
I wrote in .zshrc as follows with reference to Use virtual environment in any place with pipenv (Bash people write in .bashrc) Please give me)
~/.zshrc
export PIPENV_VENV_IN_PROJECT=1
Now the .venv directory is created directly under the project directory. But I haven't been able to connect yet.
jupyter lab
Then I got an error. Apparently it is not recommended to run with root privileges, in which case you should add --allow-root
jupyter lab --allow-root
But this time nothing is displayed. I searched for various results, and after creating a configuration file, it was displayed well.
jupyter notebook --generate-config
The following was added to the beginning of the generated setting script.
~/.jupyter/jupyter_notebook_config.py
c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8080
The connection status is now displayed on the OK terminal.
Apparently, when you start jupyter with vscode, it seems that you start jupyter server at that timing. Problem 2 gets in the way.
So I set --allow-root
in vscode.
Press F1-> type "python jupyter arg" in the search field and you should see python: specify jupyter commandline argument
at the beginning. Select it and type --allow-root
.
This finally solved it.
Congratulations
Recommended Posts