jupyter-lsp / jupyterlab-lsp

Coding assistance for JupyterLab (code navigation + hover suggestions + linters + autocompletion + rename) using Language Server Protocol
https://jupyterlab-lsp.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.8k stars 148 forks source link

How to make jupyterlab-lsp work with Jupyter Lab - Launching Example Server failed: Error: spawn pyls ENOENT #63

Closed konradsemsch closed 4 years ago

konradsemsch commented 5 years ago

It might be a lame question, but I went through all the installation steps and still can't get jupyterlab-lsp to work:

node /Users/konrad/.local/share/virtualenvs/SharedEnv-r6sHwbPo/share/jupyter/lab/staging/node_modules/jsonrpc-ws-proxy/dist/server.js --port 3000 --languageServers servers.yml

image

What am I missing here?

krassowski commented 5 years ago

Hi @konradsemsch, thanks for checking out our extension. The problem on the screnshoot appears to be unrelated to the jupyterlab-lsp extension, but to the pyls language server installation. I googled "error spawn pyls enoent" and got quite a few results, including:

There are proposed solutions (mostly based on installing pep8/uninstalling some other packages) which seem to have worked for dozens of people, so I hope that this should work for you as well. Please let us know if it helps.

bollwyvl commented 5 years ago

Pyls also takes a '-d' flag which may give more output.

Not to derail the conversation too much: This case makes me think we may wish to pass debug down from notebook to the built-in servers in the upcoming python proxy, e.g.

{ "language_servers": { "python-language-server": { "argv": ["pyls"], "debug": ["pyls", "-d"] } }

For some of them, e.g. r, it might be... more complicated.

On Mon, Oct 21, 2019, 16:12 M. Krassowski notifications@github.com wrote:

Hi @konradsemsch https://github.com/konradsemsch, thanks for checking out our extension. The problem on the screnshoot appears to be unrelated to the jupyterlab-lsp extension, but to the pyls language server installation. I googled "error spawn pyls enoent" and got quite a few results, including:

There are proposed solutions (mostly based on installing pep8/uninstalling some other packages) which seem to have worked for dozens of people, so I hope that this should work for you as well. Please let us know if it helps.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/krassowski/jupyterlab-lsp/issues/63?email_source=notifications&email_token=AAALCREJJ7MBSLCNE6GKE4DQPYEJ5A5CNFSM4JCVW7CKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB3UI4A#issuecomment-544687216, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALCRHIKAXAWEMEYWY5E5TQPYEJ5ANCNFSM4JCVW7CA .

krassowski commented 4 years ago

@konradsemsch were you able to pinpoint the problem?

konradsemsch commented 4 years ago

Frankly not really, but let me share some light on what I'm doing:

When I try installing pip8 or the other listed package I get the following information:

~/DS&ML/Python/SharedEnv master*
❯ pipenv install pip8
Installing pip8…
Adding pip8 to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock (40d26d) out of date, updating to (f06529)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✘ Locking Failed!
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/resolver.py", line 69, in resolve
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pip8
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches pip8
No versions found
Was https://pypi.org/simple reachable?
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pip8
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches pip8
No versions found
Was https://pypi.org/simple reachable?

~/DS&ML/Python/SharedEnv master* 5s
❯ pipenv install pycodestyle
Installing pycodestyle…
Adding pycodestyle to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock (04d4b2) out of date, updating to (f06529)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✘ Locking Failed!
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/resolver.py", line 69, in resolve
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pip8
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches pip8
No versions found
Was https://pypi.org/simple reachable?
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pip8
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches pip8
No versions found
Was https://pypi.org/simple reachable?

None of the other recommended solutions that I came across sorted this out. Am I missing something obvious here?

bollwyvl commented 4 years ago

Pep8?

On Mon, Oct 28, 2019, 14:24 Konrad notifications@github.com wrote:

Frankly not really, but let me share some light on what I'm doing:

  • I'm managing my Python versions with pyenv and environments with pipenv
  • If I understand correctly I need to try to resolve this problem in the specific environment I'm currently working in (called SharedEnv)

When I try installing pip8 or the other listed package I get the following information:

~/DS&ML/Python/SharedEnv master*

❯ pipenv install pip8

Installing pip8…

Adding pip8 to Pipfile's [packages]…

✔ Installation Succeeded

Pipfile.lock (40d26d) out of date, updating to (f06529)…

Locking [dev-packages] dependencies…

Locking [packages] dependencies…

✘ Locking Failed!

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/resolver.py", line 69, in resolve

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps

pipenv.exceptions.ResolutionFailure: resolved_tree = resolver.resolve()

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve

pipenv.exceptions.ResolutionFailure: raise ResolutionFailure(message=str(e))

pipenv.exceptions.ResolutionFailure: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pip8

pipenv.exceptions.ResolutionFailure: No versions found

pipenv.exceptions.ResolutionFailure: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.

First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.

Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.

Hint: try $ pipenv lock --pre if it is a pre-release dependency.

ERROR: ERROR: Could not find a version that matches pip8

No versions found

Was https://pypi.org/simple reachable?

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps

pipenv.exceptions.ResolutionFailure: resolved_tree = resolver.resolve()

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve

pipenv.exceptions.ResolutionFailure: raise ResolutionFailure(message=str(e))

pipenv.exceptions.ResolutionFailure: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pip8

pipenv.exceptions.ResolutionFailure: No versions found

pipenv.exceptions.ResolutionFailure: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.

First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.

Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.

Hint: try $ pipenv lock --pre if it is a pre-release dependency.

ERROR: ERROR: Could not find a version that matches pip8

No versions found

Was https://pypi.org/simple reachable?

~/DS&ML/Python/SharedEnv master* 5s

❯ pipenv install pycodestyle

Installing pycodestyle…

Adding pycodestyle to Pipfile's [packages]…

✔ Installation Succeeded

Pipfile.lock (04d4b2) out of date, updating to (f06529)…

Locking [dev-packages] dependencies…

Locking [packages] dependencies…

✘ Locking Failed!

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/resolver.py", line 69, in resolve

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps

pipenv.exceptions.ResolutionFailure: resolved_tree = resolver.resolve()

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve

pipenv.exceptions.ResolutionFailure: raise ResolutionFailure(message=str(e))

pipenv.exceptions.ResolutionFailure: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pip8

pipenv.exceptions.ResolutionFailure: No versions found

pipenv.exceptions.ResolutionFailure: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.

First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.

Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.

Hint: try $ pipenv lock --pre if it is a pre-release dependency.

ERROR: ERROR: Could not find a version that matches pip8

No versions found

Was https://pypi.org/simple reachable?

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps

pipenv.exceptions.ResolutionFailure: resolved_tree = resolver.resolve()

pipenv.exceptions.ResolutionFailure: File "/usr/local/Cellar/pipenv/2018.11.26_2/libexec/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve

pipenv.exceptions.ResolutionFailure: raise ResolutionFailure(message=str(e))

pipenv.exceptions.ResolutionFailure: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pip8

pipenv.exceptions.ResolutionFailure: No versions found

pipenv.exceptions.ResolutionFailure: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.

First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.

Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.

Hint: try $ pipenv lock --pre if it is a pre-release dependency.

ERROR: ERROR: Could not find a version that matches pip8

No versions found

Was https://pypi.org/simple reachable?

None of the other recommended solutions that I came across sorted this out. Am I missing something obvious here?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/krassowski/jupyterlab-lsp/issues/63?email_source=notifications&email_token=AAALCRAD7XXIR7VXLKV732DQQ4U6VA5CNFSM4JCVW7CKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECN5C7Q#issuecomment-547082622, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAALCRBVPDQXE6Q3A436METQQ4U6VANCNFSM4JCVW7CA .

krassowski commented 4 years ago

To elaborate: you want to install pep8, not pip8.

pip install pep8

You can also install all other recommended dependencies for pyls with:

pip install python-language-server[all]

where - if I correctly understand how pipenv works - instead of pip you would use pipenv.

The use of pyenv itself should not be causing any problems - this is what I work with every day (however, I use pyenv-virtualenv rather than pipenv).

Hope this helps!

konradsemsch commented 4 years ago

Yeah, you're absolutely right about the usage of pipenv. In my previous example that was just a typo: the installation did not work with pep8 either, but the reason for this was that I messed up something up in the Pepfile. Long story short, I managed to get these packages installed and currently my env has the following packages:

SharedEnv-r6sHwbPo ❯ cat Pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
numpy = "*"
pandas = "*"
scikit-learn = "*"
jupyterlab = "*"
nodejs = "*"
npm = "*"
python-language-server = {extras = ["all"],version = "*"}
pep8 = "*"
jep = "*"
jedi = "*"
pyspark = "*"
virtualenv = "*"
pycodestyle = "*"

[requires]
python_version = "3.7"

However, this hasn't fully fixed the problem. When I'm launching the notebook I get a different error message this time:

~/DS&ML/Python/SharedEnv master*
SharedEnv-r6sHwbPo ❯ node /Users/konrad/.local/share/virtualenvs/SharedEnv-r6sHwbPo/share/jupyter/lab/staging/node_modules/jsonrpc-ws-proxy/dist/server.js --port 3000 --languageServers servers.yml
Listening to http and ws requests on 3000
Forwarding new client
Example Server: 2019-10-29 22:18:45,275 UTC - ERROR - pyls_jsonrpc.endpoint - Failed to handle notification textDocument/didChange: {'textDocument': {'uri': 'file:///PythonReferences/PythonReferences_Pandas.ipynb.python', 'version': 0}, 'contentChanges': [{'text': "import pandas as pd\n\n\n# The simplest data frame possible\npd.DataFrame({'Yes': [50, 21], 'No': [131, 2]})\n\n\npd.DataFrame({'Bob': ['I liked it.', 'It was awful.'], 'Sue': ['Pretty good.', 'Bland.']})\n\n\n# In the following way we can get the index assigned ourselves\npd.DataFrame({'Bob': ['I liked it.', 'It was awful.'], \n              'Sue': ['Pretty good.', 'Bland.']},\n             index=['Product A', 'Product B'])\n\n\n# A Series, by contrast, is a sequence of data values. If a DataFrame is a table, a Series is a list\npd.Series([1, 2, 3, 4, 5])\n\n\npd.Series([30, 35, 40], index=['2015 Sales', '2016 Sales', '2017 Sales'], name='Product A')\n\n\n# *.shape() - to see the dimensions\n# pd.read_csv() - this function has over 30 arguments and methods attached to it so it's worth checking them out!\n# *.head() - to see the first couple of rows along with headers\n\n\ndf = pd.DataFrame({'Yes': [50, 21], 'No': [131, 2]})\n\n\ndf.Yes\n\n\ndf['Yes']\n\n\ndf['Yes'][0] # this is going down to a specific serie object level\n\n\ndf['Yes'][0:]\n\n\ndf.iloc[0] # that's selecting the first row of the data based on the index value\n\n\ndf.iloc[:, 0] # in order to get the first column we would need to write this\n\n\ndf.iloc[, 0] # not passing the colon would result in an error\n\n\ndf.iloc[[0, 1], 0] # there's a number of different ways of defining this\n\n\ndf.iloc[-1:] # the last x rows could be retrieved like this\n\n\ndf.loc[0, 'No'] # the difference between iloc and loc is that iloc works only based on 'indices' whereas loc works based on 'labels'\n\n\ndf.loc[0:1, 'No']\n\n\ndf.loc[1, 'Yes']\n\n\ndf.loc[:, ['Yes', 'No']]\n\n\ndf.loc[df.Yes == 50] # for boolean based conditional selection we always need to use 'loc' - the reason for this is that we're\n# evaluating on a set of boolean series. Otherwise this operation would not work\n\n\ndf.loc[(df.Yes == 50) & (df.No > 150)] # we can also easily combine conditions together using '&' and '\\'\n\n\ndf['Cat'] = ['Miau', 'Hau'] # pandas comes with a handy function for evaluating conditions for categorical columns called '.isin()'\n\ndf.loc[df['Cat'].isin(['Miau'])]\n\n\ndf.Yes\n\n\n# another set of usefull functions are '.isnull()' and '.notnull()''\ndf.loc[df['Cat'].isnull()]\n\nprint('## Break ##')\n\ndf.loc[df['Cat'].notnull()]\n\n\ndf.describe()\n\n\ndf.Yes.describe()\n\n\ndf.mean()\n\n\ndf.Yes.mean()\n\n\ndf.unique() # needs to be executed on a single column\n\n\ndf.Yes.unique()\n\n\ndf.Yes.value_counts() # to get a summary input that is histogram ready; a distribution Serie\n\n\ndf_yes_mean = df.Yes.mean()\nprint(df_yes_mean)\nprint(df.Yes)\n\n\ndf.Yes.map(lambda p: p - df_yes_mean)\n\n\n# The difference between map and apply is the following: maps works with series and apply works with entire data frames\ndef remean_points(row):\n    row.Yes = row.Yes - df_yes_mean\n    return row\n\ndf.apply(remean_points, axis='columns')\n\n\n# If we passed apply() with argument axis='index' then we would need to pass a function to modify the columns\ndef new_mean(column):\n    return sum(column)/len(column)\n\ndf[['Yes', 'No']].apply(new_mean, axis='index')\n\n\n# dtype() / df.dtypes / df.col.dtype - to get the type of the object\n# Remember that columns that are only strings get a type called 'object'\n# astype() / df.col.astype() - will convert a column from one type to another\n\n\n# fillna() / df.col.fillna('Fill') - that's a way to fill in missing data with a given value\n# replace() / df.col.replace('Value1', 'Value2') - that's a way to replace one value for another\n\n\n# Below is a couple usefull ways of using the groupby() function\n# df.groupby('col').col.count() - this expression is equivalent to running df.col.value_counts()\n# df.groupby('col').col.min()\n# df.groupby('col1').apply(lambda df: df.col2.iloc[0]) - extract the first value of col2 by each group of col1 value\n# df.groupby(['col1', 'col2']).apply(lambda df: df.loc[df.col3.idxmax()]) - you can also group by 2 columns\n# df.groupby(['col1']).col2.agg([len, min, max]) - the agg() expression let's you combine multime metrics from group by\n\n\n# Use the reset_index() function to reset df indexing\n\n\n# df.sort_values(by = 'col') - you can sort values of a data frame by specifying a given column\n# df.sort_values(by = 'col', ascending = False) - another setting for sorting\n# df.sort_index() - you can also sort by the values of your index\n# df.sort_values(by = ['col1', 'col2']) - you can also provide more than one value for sorting like that\n\n\n# df.rename(columns={'col1': 'col2'}) - this syntax will change the name of col1 into col2\n# df.rename(index={0: 'firstEntry', 1: 'secondEntry'}) - you can also change particular elements of the index; 1sr and 2nd respectively\n\n\n# pd.concat([df1, df2]) - pd.concat will just stack df's together like bind_rows would do\n# join.<option> - this is the full scale joining function based on the in-built index\n"}]}
Traceback (most recent call last):
  File "/Users/konrad/.local/share/virtualenvs/SharedEnv-r6sHwbPo/lib/python3.7/site-packages/pyls_jsonrpc/endpoint.py", line 142, in _handle_notification
    handler_result = handler(params)
  File "/Users/konrad/.local/share/virtualenvs/SharedEnv-r6sHwbPo/lib/python3.7/site-packages/pyls_jsonrpc/dispatchers.py", line 23, in handler
    return method(**(params or {}))
  File "/Users/konrad/.local/share/virtualenvs/SharedEnv-r6sHwbPo/lib/python3.7/site-packages/pyls/python_ls.py", line 301, in m_text_document__did_change
    version=textDocument.get('version')
  File "/Users/konrad/.local/share/virtualenvs/SharedEnv-r6sHwbPo/lib/python3.7/site-packages/pyls/workspace.py", line 77, in update_document
    self._docs[doc_uri].apply_change(change)
KeyError: 'file:///PythonReferences/PythonReferences_Pandas.ipynb.python'

It seems to still be related to pyls - any ideas on what I should do?

krassowski commented 4 years ago

This is a duplicate of #33 and #64 and should not really affect the functionality of the extension - have you tried to see if any linter messages (or other functionality of this extension) show up/work in this notebook?

konradsemsch commented 4 years ago

Well, some are working and some are not. I have an impression that not all are working/ some work with a very large lag. For instance this automatic signature suggestion practically doesn't work:

image

krassowski commented 4 years ago

It does work when static analysis can infer the signature: Screenshot from 2019-10-30 20-11-58

In your pandas case the created object is either not analyzed, or pandas cannot be analyzed/imported in your environment (e.g. it is not installed or it is installed but not in the same environment as jupyterlab-lsp/LSP server).

If there are cases that do not work for you, please consult the Language Server (here pyls) documentation and open an issue on their repository: https://github.com/palantir/python-language-server. They have a new maintainers team and started working on ensuring that major functionalities work correctly with the basic Python scientific stack.

Also, if you are able to demonstrate that some function for given code snippet works in another LSP client (VSCode with pyls, vim, emcas or another with pyls) but not with jupyterlab-lsp, please do open an issue here describing it in detail and we will investigate.

I am closing this one as there were only user-configuration issues / false-positive warnings specific to pyls server (see the linked duplicate threads). Happy that we could help and you got your configuration up and runnig.