Repository: spyder-ide/spyder

Issue:
PATH problem since updating macOS
After updating macOS to Mojave, I had an issue launching spyder:
'pyls' is not found by `subprocess.Popen` because `/usr/local/bin` is not in `os.environ['PATH']`

I fixed it by adding in spyder/plugins/editor/lsp/client.py before [Line 127](https://github.com/spyder-ide/spyder/blob/a3af9c758e2e9fc25564b73a114e491deb299e11/spyder/plugins/editor/lsp/client.py#L127)

`os.environ['PATH'] +=':/usr/local/bin'`

<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

### Issue Report Checklist

* [x] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [ ] Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* [ ] Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* [ ] Could not reproduce inside ``jupyter qtconsole`` (if console-related)
* [ ] Tried basic troubleshooting (if a bug/error)
    * [ ] Restarted Spyder
    * [ ] Reset preferences with ``spyder --reset``
    * [ ] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [ ] Tried the other applicable steps from the Troubleshooting Guide
* [ ] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below


## Problem Description



### What steps reproduce the problem?

1. 
2. 
3. 

### What is the expected output? What do you see instead?



### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

PASTE TRACEBACK HERE

```

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 
* Python version: 
* Qt version: 
* PyQt version: 
* Operating System name/version: 

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
PASTE DEPENDENCIES HERE
```



Discussion:
Thanks for the report @impact27! We'll fix this for beta2 (we certainly need to be more robust about finding `pyls`).
@dalthviz, please work on this one. We should use

    sys.executable -m pyls

to start pyls.

Resolving patch:
diff --git a/spyder/plugins/editor/lsp/client.py b/spyder/plugins/editor/lsp/client.py
--- a/spyder/plugins/editor/lsp/client.py
+++ b/spyder/plugins/editor/lsp/client.py
@@ -96,7 +96,7 @@ def __init__(self, parent, server_args_fmt='',
         # if self.external_server:
         transport_args = self.external_server_fmt % (server_settings)
 
-        self.server_args = [server_settings['cmd']]
+        self.server_args = [sys.executable, '-m', server_settings['cmd']]
         self.server_args += server_args.split(' ')
         self.transport_args += transport_args.split(' ')
         self.transport_args += ['--folder', folder]
diff --git a/spyder/plugins/editor/lsp/transport/producer.py b/spyder/plugins/editor/lsp/transport/producer.py
--- a/spyder/plugins/editor/lsp/transport/producer.py
+++ b/spyder/plugins/editor/lsp/transport/producer.py
@@ -21,6 +21,7 @@
 import json
 import time
 import socket
+import sys
 import logging
 import subprocess
 from spyder.py3compat import getcwd
@@ -53,7 +54,7 @@ def __init__(self, host='127.0.0.1', port=2087, workspace=getcwd(),
         if not use_external_server:
             LOGGER.info('Starting server: {0} {1} on {2}:{3}'.format(
                 server, ' '.join(server_args), self.host, self.port))
-            exec_line = [server] + server_args
+            exec_line = [sys.executable, '-m', server] + server_args
             LOGGER.info(' '.join(exec_line))
 
             self.server = subprocess.Popen(


Test patch: