mlshapiro / jupyterlab-flake8

Jupyterlab python linter for notebooks and text files using flake8
BSD 3-Clause "New" or "Revised" License
110 stars 10 forks source link

Menu items greyed out and linting not enabled #37

Open joelostblom opened 4 years ago

joelostblom commented 4 years ago

Thanks for making this! Unfortunately I can't get it to work, the menu items are greyed out. I have flake8 installed both in my conda env and system wide. I tried both with the base conva env current one. Logging is true in the config. I can open a terminal in JL and which flake8 shows me the path to my conda installed flake8. There are no error message in the terminal from which I run JL and I could not see anything related to flake8 in the firefox console log. I am Not sure what to try next. I installed the plugin today.

flake8              3.7.9
IPython             6.5.0
jupyter_client      5.2.3
jupyter_core        4.6.3
jupyterlab          2.1.0
notebook            5.6.0
-----
Python 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 23:03:20) [GCC 7.3.0]
Linux-5.6.2-arch1-2-x86_64-with-arch
4 logical CPU cores
-----
jorge-fresh4cast commented 4 years ago

Same here... terminal runs but the extension remains greyed out.

zaneselvans commented 4 years ago

I'm having the same issue. The plugin does add extra space in the margin on the left hand side of every cell, where linting error indicators would show up, but no linting is happening.

ghost commented 4 years ago

same issue here

mlshapiro commented 4 years ago

Would one of you be able to enable the browser logs and copy them here? I only have OSX to try this out, and I wonder if this may be operating system dependent.

ghost commented 4 years ago

Thanks for creating this. It is very helpful!

I'm on a Google Cloud Platform Virtual Machine (and port forwarding Jupyter Lab).

System & package version info:

$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ conda --version
conda 4.8.3
$ conda create -n test python=3.7.6
$ conda activate test
$ pip install jupyterlab
$ conda install nodejs

Then I installed jupyterlab-flake8 in the console (I had tried installing it via command line, doesn't seem to matter much)

Here's what I'm seeing

Screenshot 2020-05-28 at 3 09 36 PM

Browser console logs:

react-dom.development.js:25195 Download the React DevTools for a better development experience: https://fb.me/react-devtools
index.js:50 Starting application in workspace: "/lab"
default.js:38 WebSocket connection to 'ws://localhost:8888/terminals/websocket/?token=7d71db24ee36ba2ae4aa4d2d5d28d8d89aa761981892fcdb' failed: Error during WebSocket handshake: Unexpected response code: 302
TerminalConnection._createSocket @ default.js:38
TerminalConnection @ default.js:89
connectTo @ manager.js:108
(anonymous) @ index.js:107
(anonymous) @ index.js:8
push.bX36.__awaiter @ index.js:4
load_linter @ index.js:93
(anonymous) @ index.js:63
default.js:69 Terminal websocket closed: undefined
TerminalConnection._onWSClose @ default.js:69
error (async)
TerminalConnection._createSocket @ default.js:41
TerminalConnection @ default.js:89
connectTo @ manager.js:108
(anonymous) @ index.js:107
(anonymous) @ index.js:8
push.bX36.__awaiter @ index.js:4
load_linter @ index.js:93
(anonymous) @ index.js:63
Promise.then (async)
Linter @ index.js:55
activate @ index.js:788
(anonymous) @ index.js:156
Promise.then (async)
push.2dC9.Application.activatePlugin @ index.js:155
(anonymous) @ index.js:275
push.2dC9.Application.start @ index.js:274
main @ index.out.js:1011
load (async)
ANye @ index.out.js:1057
__webpack_require__ @ bootstrap:83
0 @ bootstrap:221
__webpack_require__ @ bootstrap:83
checkDeferredModules @ bootstrap:44
webpackJsonpCallback @ bootstrap:31
(anonymous) @ vendors~main.bda80588873e29f59391.js:1
default.js:226 Connection lost, reconnecting in 0 seconds.
_reconnect @ default.js:226
TerminalConnection._onWSClose @ default.js:71
error (async)
TerminalConnection._createSocket @ default.js:41
TerminalConnection @ default.js:89
connectTo @ manager.js:108
(anonymous) @ index.js:107
(anonymous) @ index.js:8
push.bX36.__awaiter @ index.js:4
load_linter @ index.js:93
(anonymous) @ index.js:63
Promise.then (async)
Linter @ index.js:55
activate @ index.js:788
(anonymous) @ index.js:156
Promise.then (async)
push.2dC9.Application.activatePlugin @ index.js:155
(anonymous) @ index.js:275
push.2dC9.Application.start @ index.js:274
main @ index.out.js:1011
load (async)
ANye @ index.out.js:1057
__webpack_require__ @ bootstrap:83
0 @ bootstrap:221
__webpack_require__ @ bootstrap:83
checkDeferredModules @ bootstrap:44
webpackJsonpCallback @ bootstrap:31
(anonymous) @ vendors~main.bda80588873e29f59391.js:1
default.js:252 WebSocket connection to 'ws://localhost:8888/terminals/websocket/?token=7d71db24ee36ba2ae4aa4d2d5d28d8d89aa761981892fcdb' failed: WebSocket is closed before the connection is established.
_clearSocket @ default.js:252
dispose @ default.js:131
(anonymous) @ manager.js:203
requestRunning @ manager.js:201
async function (async)
requestRunning @ manager.js:181
factory @ manager.js:37
push.V8jV.Poll._execute @ poll.js:339
execute @ poll.js:278
requestAnimationFrame (async)
(anonymous) @ poll.js:282
step @ poll.js:46
(anonymous) @ poll.js:27
fulfilled @ poll.js:18
Promise.then (async)
step @ poll.js:20
(anonymous) @ poll.js:21
push.V8jV.__awaiter @ poll.js:17
push.V8jV.Poll.schedule @ poll.js:242
push.V8jV.Poll.refresh @ poll.js:218
refreshRunning @ manager.js:137
connectTo @ manager.js:113
(anonymous) @ index.js:107
(anonymous) @ index.js:8
push.bX36.__awaiter @ index.js:4
load_linter @ index.js:93
(anonymous) @ index.js:63
Promise.then (async)
Linter @ index.js:55
activate @ index.js:788
(anonymous) @ index.js:156
Promise.then (async)
push.2dC9.Application.activatePlugin @ index.js:155
(anonymous) @ index.js:275
push.2dC9.Application.start @ index.js:274
main @ index.out.js:1011
load (async)
ANye @ index.out.js:1057
__webpack_require__ @ bootstrap:83
0 @ bootstrap:221
__webpack_require__ @ bootstrap:83
checkDeferredModules @ bootstrap:44
webpackJsonpCallback @ bootstrap:31
(anonymous) @ vendors~main.bda80588873e29f59391.js:1
react-dom.development.js:11494 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

Please update the following components: CollapsibleSection
printWarning @ react-dom.development.js:11494
lowPriorityWarning @ react-dom.development.js:11513
push.Ybsr.ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings @ react-dom.development.js:11680
flushRenderPhaseStrictModeWarningsInDEV @ react-dom.development.js:23134
commitRootImpl @ react-dom.development.js:22428
unstable_runWithPriority @ scheduler.development.js:643
runWithPriority$2 @ react-dom.development.js:11305
commitRoot @ react-dom.development.js:22414
runRootCallback @ react-dom.development.js:21554
(anonymous) @ react-dom.development.js:11353
unstable_runWithPriority @ scheduler.development.js:643
runWithPriority$2 @ react-dom.development.js:11305
flushSyncCallbackQueueImpl @ react-dom.development.js:11349
flushSyncCallbackQueue @ react-dom.development.js:11338
scheduleUpdateOnFiber @ react-dom.development.js:21431
scheduleRootUpdate @ react-dom.development.js:24319
updateContainerAtExpirationTime @ react-dom.development.js:24347
updateContainer @ react-dom.development.js:24436
legacyRenderSubtreeIntoContainer @ react-dom.development.js:24975
render @ react-dom.development.js:25042
(anonymous) @ vdom.js:57
renderDOM @ vdom.js:52
onUpdateRequest @ vdom.js:30
push.+9p4.Widget.processMessage @ widget.js:503
invokeHandler @ index.js:438
sendMessage @ index.js:174
runMessageLoop @ index.js:488
requestAnimationFrame (async)
enqueueMessage @ index.js:457
postMessage @ index.js:225
push.+9p4.Widget.update @ widget.js:359
invokeSlot @ index.js:470
emit @ index.js:427
push.frNV.Signal.emit @ index.js:108
update @ model.js:518
async function (async)
update @ model.js:498
initialize @ model.js:186
_listingIsLoaded @ model.js:102
invokeSlot @ index.js:470
emit @ index.js:427
push.frNV.Signal.emit @ index.js:108
(anonymous) @ listings.js:43
Promise.then (async)
Lister @ listings.js:19
ListModel @ model.js:54
ExtensionView @ widget.js:204
createView @ index.js:31
activate @ index.js:41
async function (async)
activate @ index.js:26
(anonymous) @ index.js:156
Promise.then (async)
push.2dC9.Application.activatePlugin @ index.js:155
(anonymous) @ index.js:275
push.2dC9.Application.start @ index.js:274
main @ index.out.js:1011
load (async)
ANye @ index.out.js:1057
__webpack_require__ @ bootstrap:83
0 @ bootstrap:221
__webpack_require__ @ bootstrap:83
checkDeferredModules @ bootstrap:44
webpackJsonpCallback @ bootstrap:31
(anonymous) @ vendors~main.bda80588873e29f59391.js:1
lab:1 A cookie associated with a cross-site resource at https://github.com/ was set without the `SameSite` attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
lab:1 A cookie associated with a cross-site resource at http://github.com/ was set without the `SameSite` attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
default.js:50 Starting WebSocket: ws://localhost:8888/api/kernels/79a9da83-372f-417d-9ea8-213c2a05371b
default.js:50 Starting WebSocket: ws://localhost:8888/api/kernels/79a9da83-372f-417d-9ea8-213c2a05371b
nuclear0wl commented 4 years ago

Hello, I've faced the same issue.

My environment is

I can't realize the cause of this issue but have found a way to fix it dirty and quickly. In JypyterLab you may go to Settings -> Advanced settings -> Jupyterlab-Flake8 and set "terminal_name" in User preferences to 1. After that save config, reload JupyterLab page in your browser and try to lint something in a Notebook.

Unfortunately, if you need to enable/disable linting regularly (I need it as this extension conflicts with @jupyterlab/debugger) you may again run into greyed menu items and absence of linting. In that case, you may go back to the User preferences of extension and find that "toggled" option is set to false. Set it to true and reload the browser page.

Hope, it may help somebody besides me and give contributor some ideas about the root cause of this issue.

tjiagoM commented 4 years ago

I'm having the same issue. The manual solution from @nuclear0wl of setting the terminal name to "1" seems to solve the issue temporarily for the current open file, but then when changing it just breaks down.

ddobrinskiy commented 4 years ago

Same here.

❯ jupyter labextension list
JupyterLab v2.2.8
Known labextensions:
   app dir: /home/david/miniconda3/share/jupyter/lab
        jupyterlab-flake8 v0.6.1  enabled  OK

See log output below image

mlshapiro commented 3 years ago

I set a default terminal name (flake8term) in this latest build for Jupyter 0.3. Does this solve the loading issue?

LloydThinks commented 2 years ago

I am having a similar issue. Just loaded fresh on macOS following the installation guide and the linter is not running. The grey margin on the left is there, but no linting is occurring.

ethanblatti commented 2 years ago

I have found a workaround for this.

I am on Jupyterlab 3.2.1 and jupyterlab-flake8 v.0.7.0

  1. After starting jupyter lab open the settings for the plugin Settings > Advanced Settings Editor > Jupyterlab-Flake8
  2. Set the terminal name to "1" "terminal_name": "1"
  3. Set toggled to false "toggled": false
  4. Save the settings
  5. Open a new terminal in jupyter lab File > New > Terminal Note: the terminal's name should automatically be Terminal 1
  6. Set toggled to true "toggled": true
  7. Save settings

After saving the settings the linter will begin working and the menu options under view are no longer grayed out.

Unfortunately I have to do this each time I restart my jupyter lab instance but it is what has worked for me.

--- EDIT --- Whoops, just saw @nuclear0wl's comment above. Glad we came to the same dirty fix

volfi commented 2 years ago

For me the solutions by @ethanblatti & @nuclear0wl did not work. My workaround is still quite similar:

Make sure terminal name is set to 1 and toggled is set to true. All terminals need to be shut down. To be sure terminate the session and restart from conda. Go to file and hit new terminal. Then reload browser. In Terminal type conda env list. Flake8 extension should work now and start linting once .py-files are opened.

goekce commented 2 years ago

After trying the helpful workarounds I spent more time understanding what is happening in Firefox:


Starting application in workspace: "default" jlab_core.fa2ded6823988d66523d.js:2:5779
jupyterlab-flake8: loaded settings {"toggled":true,"lint_on_change":true,"logging":true,"highlight_color":"var(--jp-warn-color3)","gutter_color":"var(--jp-error-color0)","term_timeout":5000,"conda_env":"base","terminal_name":"flake8term","configuration_file":""} index.js:717
jupyterlab-flake8: set terminal_name to flake8term index.js:717
Firefox can’t establish a connection to the server at wss://server.com/user/u/terminals/websocket/flake8term. jlab_core.fa2ded6823988d66523d.js:2:1023780
The connection to wss://server.com/user/u/terminals/websocket/flake8term was interrupted while the page was loading. jlab_core.fa2ded6823988d66523d.js:2:1023780
jupyterlab-flake8: loaded settings {"toggled":true,"lint_on_change":true,"logging":true,"highlight_color":"var(--jp-warn-color3)","gutter_color":"var(--jp-error-color0)","term_timeout":5000,"conda_env":"base","terminal_name":"flake8term","configuration_file":""} index.js:717
Source map error: Error: request failed with status 404
Resource URL: https://server.com/user/u/static/lab/jlab_core.fa2ded6823988d66523d.js?v=fa2ded6823988d66523d
Source Map URL: jlab_core.fa2ded6823988d66523d.js.map?v=fa2ded6823988d66523d

It seems like the extension cannot start the terminal. In the Jupyterlab tab Running Terminals and Tabs the terminal flake8term can also not be found. Toggling the extension also does not help:

jupyterlab-flake8: loaded settings {"toggled":false,"lint_on_change":true,"logging":true,"highlight_color":"var(--jp-warn-color3)","gutter_color":"var(--jp-error-color0)","term_timeout":5000,"conda_env":"base","terminal_name":"flake8term","configuration_file":""} index.js:717
jupyterlab-flake8: disposing flake8 and terminal index.js:717
Source map error: Error: request failed with status 404
Resource URL: https://server.com/user/u/static/lab/jlab_core.fa2ded6823988d66523d.js?v=fa2ded6823988d66523d
Source Map URL: jlab_core.fa2ded6823988d66523d.js.map?v=fa2ded6823988d66523d

jupyterlab-flake8: loaded settings {"toggled":true,"lint_on_change":true,"logging":true,"highlight_color":"var(--jp-warn-color3)","gutter_color":"var(--jp-error-color0)","term_timeout":5000,"conda_env":"base","terminal_name":"flake8term","configuration_file":""} index.js:717
jupyterlab-flake8: set terminal_name to flake8term

GET  ... Not Found

Then I set terminal_name to 1, because we can then open the terminal (that this extension uses to pipe the code to flake8) manually. Then I toggled, and saw messages similar to above.

I opened a new terminal and could see under Running Terminals and Tabs terminals/1. I toggled the extension and could see both in the Firefox developer console and in terminals/1 the initialization commands of the extension:

[u@s ~]$ python -c "import os; print(os.name)"
posix
[u@s ~]$ HISTFILE= ;
[u@s ~]$

Then I opened an existing notebook and could see the red error dots beside the code. In the same time you can also see in terminals/1 how the code is piped through flake8.

I also noticed:

goekce commented 2 years ago

If you are looking for another PEP8 linter: https://github.com/jupyter-lsp/jupyterlab-lsp

joelostblom commented 2 years ago

I am also using jupyter-lsp now for linting and it works great!