Home > OS >  Can't find jedi-language-server in command line in mac but can in Linux
Can't find jedi-language-server in command line in mac but can in Linux

Time:12-10

Questions

I install jedi-language-server as the README.md. but I can't find jedi-language-server --help in My Mac(13 Ventura) system. But I can find this package in the pip list.

➜  ~ pip3 list | grep jedi
jedi                  0.18.2
jedi-language-server  0.40.0

PATH and others

This is my new machine, not use conda or other venv moudle.

➜  ~ echo $PATH
/Users/vzgoll/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin
➜  ~ which jedi-language-server
jedi-language-server not found
➜  ~ python3 -m site                
sys.path = [
    '/Users/vzgoll',
    '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python39.zip',
    '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9',
    '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/lib-dynload',
    '/Users/vzgoll/Library/Python/3.9/lib/python/site-packages',
    '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages',
]
USER_BASE: '/Users/vzgoll/Library/Python/3.9' (exists)
USER_SITE: '/Users/vzgoll/Library/Python/3.9/lib/python/site-packages' (exists)
ENABLE_USER_SITE: True

In order to verify, I install jedi-language-server in my Arch Linux, It can use command jedi-language-server --help

So I want to ask why this happened.

Solution

Add following code in my ~/.zshrc.

pythonUserBaseDir=$(python3 -m site --user-base);
pythonUserBaseBinDir="$pythonUserBaseDir/bin"
export PATH="$pythonUserBaseBinDir:$PATH"
unset pythonUserBaseDir;
unset pythonUserBaseBinDir;

CodePudding user response:

It's a $PATH problem.

You didn't reveal anything about your conda or venv config, and you didn't show us what $ echo $PATH says. You should have a python project environment for installing jedi and dependencies. When you activate the environment, the relevant /bin directory should be added to your $PATH. Apparently that only happened properly on your Linux install.

Use $ which jedi-language-server and $ ls -l to debug the details, so your Mac config resembles the (working) Linux config.

Use $ python -m site to examine the python library install directories. Notice how its output changes when you activate or deactivate the project environment.

EDIT

You're not using a project environment for python library installs? I don't recommend that.

There are very good reasons for using such an environment, which the current question is highlighting.

Perhaps you used sudo when you pip installed it? Where did the install go? Use ls -l or find to locate it. Verify that you have permission to read the root-owned file. Verify that you have added its directory to your $PATH environment variable.

You have two environments, one of them working. Use the tools mentioned above to find how they differ, and to repair the faulty install.

Focus on that /Users/vzgoll/Library/Python/3.9/lib/python/site-packages directory. You should see several recently installed libraries in there, perhaps including jedi. Sometimes a library will include a bin directory under site-packages. You should be able to run binaries by giving the full path, or more conveniently by appending the bin directory to your $PATH env var.

  • Related