Atom / Pip / Python Language Server


#1

Hello I am trying to learn python using atom. As I am writing my first script everything is fine BUT atom is telling me:

Unable to start Python Language server. Make sure to install pals 0.19 or newer by running…
python -m pip install ‘python-language-server[all]’

My environment is:

atom - 1.13.2
python - 2.7.10
Mac OS - Mojave 10.14

When trying this command I am getting the following error:

Tom$ sudo -H python2.7 -m pip install ‘python-language-server[all]’
Collecting python-language-server[all]
Downloading https://files.pythonhosted.org/packages/9f/1d/2817b5dc2dd77f897410a11c1c9e2a6d96b3273c53d4219dd9edab7882af/python-language-server-0.21.2.tar.gz (51kB)
100% |################################| 61kB 1.4MB/s
Complete output from command python setup.py egg_info:
error in python-language-server setup command: ‘install_requires’ must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in configparser; python_version<“3.0” at ; python_version<“3.0”

----------------------------------------

Command “python setup.py egg_info” failed with error code 1 in /private/tmp/pip-install-XoKRFw/python-language-server/

Can someone help me clear this error so I can continue? Thank you.


#2

Is there a reason you need sudo for this?

Can someone help me clear this error so I can continue?

If you are still having difficulty installing PyLS after you try it without sudo, you can disable ide-python until you find someone who can help you install the language server on Mac. That will quiet the error.


#3

There is no reason I used sudo just part of trying to make it work on my part. The error is the same with or without sudo.

Hopefully someone can advise how to correct this.


#4

According to the python-language-server docs:

If you get an error similar to ‘install_requires’ must be a string or list of strings then please upgrade setuptools before trying again.

There’s another inconsistency. I don’t know the inner workings of ide-python and don’t have time to investigate now, but I suspect that it likely uses the python command to try to invoke the language server. The command you’re using is for Python 2, specifically. If python points to Python 3, then you should probably install the language server under that command.


#5

Tried adding the version 2.7 to the command with no luck before I posted as that does seem to be the crux of the issue but Atom can’t tell me what needs to be done here. I do appreciate your suggestions.


#6

What happens if you upgrade setuptools?


#7

Thanks for the reply. I checked into the Atom application and in the ‘install packages’ section typing in setuptool does not reveal a package of this name? Are you referring to something else, if so what?

Thank you


#8

If you follow the link I posted and look for the text that I quoted, you will see a command:

pip install -U setuptools

Run this on your system command line to upgrade the setuptools you have installed.


#9

Thank you for the clarification, I ran the command and I don’t think it worked because I got a very long that equally as unclear.

Collecting setuptools

Downloading https://files.pythonhosted.org/packages/96/06/c8ee69628191285ddddffb277bd5abdf769166e7a14b867c2a172f0175b1/setuptools-40.4.3-py2.py3-none-any.whl (569kB)

100% |████████████████████████████████| 573kB 6.7MB/s 

Installing collected packages: setuptools

Found existing installation: setuptools 18.5

Uninstalling setuptools-18.5:

Could not install packages due to an EnvironmentError: [(’/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc’, ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc’, “[Errno 1] Operation not permitted: ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc’”), (’/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py’, ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py’, “[Errno 1] Operation not permitted: ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.py’”), (’/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py’, ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py’, “[Errno 1] Operation not permitted: ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py’”), (’/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc’, ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc’, “[Errno 1] Operation not permitted: ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/init.pyc’”), (’/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib’, ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib’, “[Errno 1] Operation not permitted: ‘/private/var/folders/0s/b4r16hdn0h73qzfp0zp69jgw0000gn/T/pip-uninstall-lLh52d/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib’”)]


#10

I’ve never seen that error before, and based on the error message (it talks about permission and includes a lot of Mac-specific folders like), my best guess is that it’s Mac-related. Sure enough, if I type pip mac operation not permitted into Google, this is the first result. If you use the --user flag to install a package that also exists inside /System/Library/Frameworks/Python.framework/Versions/2.7/, the one in your user folder should take precedence. Here’s some extra reading on how Python locates packages.


#11

I had googled prior to posting here and the issue is the same when using the ‘—user’ flag as follows:

python2.7 -m pip install ‘python-language-server[all]’ –user

Collecting python-language-server[all]

Using cached …://files.pythonhosted.org/packages/9f/1d/2817b5dc2dd77f897410a11c1c9e2a6d96b3273c53d4219dd9edab7882af/python-language-server-0.21.2.tar.gz

Complete output from command python setup.py egg_info:

error in python-language-server setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in configparser; python_version&lt;"3.0" at ; python_version&lt;"3.0"

sudo made no difference either.

Its crap like this that just drives me to drink….


#12

That’s the same error as before, which setuptools is supposed to fix. You definitely got setuptools installed correctly with the --user flag?


#13

DS, I do believe that the setup tools was upgraded and installed correctly using the —user flag as shown below.

macbook$ pip install -U setuptools --user
Collecting setuptools
Using cached xxxx://files.pythonhosted.org/packages/96/06/c8ee69628191285ddddffb277bd5abdf769166e7a14b867c2a172f0175b1/setuptools-40.4.3-py2.py3-none-any.whl
Installing collected packages: setuptools
Successfully installed setuptools-40.4.3

Then moving back to the language server I tried that again and in several ways, with and without the python version, with and without sudo. All failed with the same error.

MacBook-Pro:$ python2.7 -m pip install ‘python-language-server[all]’ –user
Invalid requirement: '‘python-language-server[all]’'
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-18.1-py2.7.egg/pip/_internal/req/constructors.py", line 253, in install_req_from_line
    req = Requirement(req)
  File "/Library/Python/2.7/site-packages/pip-18.1-py2.7.egg/pip/_vendor/packaging/requirements.py", line 96, in __init__
    requirement_string[e.loc:e.loc + 8], e.msg
InvalidRequirement: Parse error at "'\xe2\x80\x98pytho'": Expected W:(abcd...)

#14

The characters and are decorative symbols and not actual quote markers. Since you posted the command string without the right tags to tell the forum that the text should be preformatted, the forum did the helpful thing of displaying the pretty quote characters (which make embedded quotes much easier to read for humans, but mean nothing to the code interpreters). According to the error message, the pip parser was looking for a string composed of letters (and a few characters like -()), but it found the character represented by \xe2\x80\x98 (check out that link; it’s a wonderfully nerdy site).

If you run the command with normal single-quotes it should work just fine.


#15

DS Those are single quotes


#16

No, they aren’t. Look at the second line. '‘python-language-server[all]’'. The outermost characters are single quotes. The ones immediately inside them are not. Those are fancy punctuation characters that are displayed in place of quotes because they’re easier to read, and if you go to the page I linked you will find that the character code for matches the error message exactly.


#17

I took your information and went back to check in terminal, they were single quotes…. But for some reason in what I pasted it shows different, I thought well maybe it’s a function of just pasting it into the forum editor. Regardless to be thorough I retyped the line FRESH and tada it worked.

Thank you for your patience while I figured this out, thank you for your great links that I am sure will help me as I learn and thanks now atom works just like I had hoped it would – error free!!

Best/T2


#18

No problem. :slight_smile:

You’re never going to escape from the errors. This is an open-source project and is kind of an airplane built in midair by a bunch of different people. Things go wrong, especially when you use a community package that (in this case) relies on software built by the community for a different language. Most of Atom and its packages work most of the time, but things will need to be reset or tweaked and it helps tremendously to cultivate the attitude and the expertise to take control of how Atom and the command line for your chosen languages work, because then you’ll be able to figure out when the Python interpreter is telling you something, but Atom doesn’t know what Python errors mean.