neoclide / coc-python

Python extension for coc.nvim, fork of vscode-python
574 stars 51 forks source link

RuntimeError: location not created nor specified'. Make sure pipenv is on the PATH. #28

Closed hujianxin closed 5 years ago

hujianxin commented 5 years ago

你好,我只是简单的打开了一个脚本,当前目录下也没有pipfile这个文件,但是messages里面报这个错误。

[coc.nvim] Workspace contains pipfile but attempt to run 'pipenv --venv' failed with 'Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>                                                                                                                                                     
    sys.exit(cli())
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 105, in augment_usage_errors
    yield
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 105, in augment_usage_errors
    yield
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/cli/command.py", line 136, in cli
    do_py()
  File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 1640, in do_py
    click.echo(which("python", allow_global=system))
  File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 114, in which
    raise RuntimeError("location not created nor specified")
RuntimeError: location not created nor specified'. Make sure pipenv is on the PATH.
hujianxin commented 5 years ago

而且看样子使用的python版本也不太对,我使用的应该是pyenv中的python3.7。但是通过lightline看,版本又是对的,这个还得麻烦您帮忙看一下。

image

chemzqm commented 5 years ago

你在命令行执行 pipenv --venv 这个命令正常吗?

hujianxin commented 5 years ago

在脚本所在目录下,运行pipenv --venv是这样的结果: image 另外,我在第一条所述的问题,并不是打开文件就会出现,而是在运行第三方库的跳转(goto definition)之后才出现的。

hujianxin commented 5 years ago

出现这个错误之后,我再运行format,就会报这个错: [coc.nvim] Error on 'format': Cannot read property 'fsPath' of null

之前format代码都是正常的。

chemzqm commented 5 years ago

pythonPath 找错了导致的这个问题。

hujianxin commented 5 years ago

我在 ~/.config/nvim/coc-settings.json 里面已经指定了 "python.pythonPath"了,这个还是不够吗?

因为只是写点简单脚本,所以不太好每个脚本都搞一个工程,然后放入.vim目录。

从使用vscode的经验上来看,只要在总的配置中指定一个pythonPath,应该就不会找错吧,是不是coc-python中在跳转执行之后,配置文件的位置变成了非 ~/.config/nvim/coc-settings.json的某个地方?

chemzqm commented 5 years ago

有优先级的问题,你可以查看 output channel https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel

chemzqm commented 5 years ago

Run :CocCommand python.setInterpreter to fix it.