YouCompleteMe post install error : cannot import name _compare_digest - python

I am trying to install YouCompleteMe plugin on a source compiled Vim instance. I have a server without sudo privileges, hence I had to compile new Vim (7.4+) in order to make most plugins work. Also, I have installed miniconda and thus refer to the python in miniconda for all installations.
While following all steps how to install YouCompleteMe plugin (via Vundle or even manually), I faced this issue : "Cannot find module urllib3". So I installed urllib3 via pip, and then the error changed to "cannot import name _compare_digest". Point to note that conda virtualenv (I have just made the miniconda bin to $PATH) cannot start and it still shows "Cannot find module urllib3" even after installing it explicitly.
Is there something wrong with the way I installed vim? I had been extra careful to point to miniconda python wherever it's needed. How do I mitigate this issue and get the plugin running again?

When I had trouble with dependencies I had to run
git submodule update --init --recursive
in the YouCompleteMe directory to get the dependencies installed.
Also make sure you have taken all of the other steps here:
https://valloric.github.io/YouCompleteMe/#full-installation-guide
One of those steps may fix the issue.

In Short
Just go to ycmd submodule inside YouCompleteMe folder, or to be exact in the YouCompleteMe/third_party/ycmd and the run the git submodule command bellow.
git submodule update --init --recursive
Explantion
I've got the same issue like yours,
It was caused by the submodule of YouCompleteMe not being cloned properly.
This command should be able to solve the problem.
git submodule update --init --recursive
But unfortunately the problem still persist, the problem at which urllib3 not found , and instlling the library using pip won't be able to solve this issue.
The problem actually located in ycmd submodule at which needing urllib3 or to be more precise the requests submodule of ycmd needed it.
After some experimenting, the main problem was the git submodule command unable to properly clone the submodule, at which rasing an error about module not found.
Hope, this can be a help for you :)

Related

How to install Python package from GitHub that doesn't have setup.py in it

I would like to use the following sdk in my python project -> https://github.com/LBank-exchange/lbank-api-sdk-v2. It has sdk's for 3 languages (I just want the python one). I tried to install it using the command:
pip install git+https://github.com/LBank-exchange/lbank-api-sdk-v2.git#egg=lbank
which gave the error
does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.
Looks like the developer didn't bother to package it properly. It it was me using it, I would fork it on GH, add the setup.py and use the fork. Maybe a good exercise for you?
Meanwhile, to just get it to work, in your project "root":
git clone https://github.com/LBank-exchange/lbank-api-sdk-v2.git
ln -s lbank-api-sdk-v2/python-sdk-api/LBank ./LBank
Then in your code just import LBank. This will leave the cloned repo untouched (so you can git pull to update it later) and just link the module directory to the root. Alternatively you can just include the api directory in sys.path for imports to work.
Think there is nothing to install, if you want to be able to "import" and use it like other packages you install through pip install you can just add the folder to your sys-path:
import sys
sys.path.append("path")

`ModuleNotFoundError` When Importing Python Package from Git

I'm attempting to install a featurestore package from a private GitHub repo via ssh with the following command:
pip3 install -U git+ssh://git#dsghe.<mydomain>/bshelton/package_test.git#master#egg=featurestore
The install is successful, per the image below:
But when trying to run from featurestore import *, I get a ModuleNotFoundError: No module named 'featurestore' error.
Using pip3 freeze, I see that the package is installed, but not with the <package>==<version> syntax I would expect, but it seems to be referencing the git commit instead as its "version":
I believe that the repo's directory set-up is appropriate for a Python package, per the screenshot below.
A noticeable difference between this package's install and the other packages I've installed is that it seems like only the ...dist-info folder is installed for my featurestore package, while every other installed package includes the actual package directory, in addition to the ...dist-info folder. Using ls ~/.local/lib/python3.6/site-packages:
This is my first time, trying to create a package like this, and I've been referencing the several sources below, but would appreciate some insight from the community as to what I'm missing. Thanks.
https://packaging.python.org/tutorials/packaging-projects/
pip install from git repo branch
The cause of my issue turned out to be a syntax error in my setup.cfg above the package_dir and packages lines, which are important if using a package layout with 'src'. Until I fixed the error, my package installed and imported fine in some contexts but not others
I was able to solve for this by moving my featurestore directory up one level, and getting rid of the src directory. Based on the top answer here, I may have been able to also solve for it by simply adding a __init__.py file directly in the src directory. But for my need, src was really an unnecessary level.
New package directory set-up:
Code ran in terminal:
!pip3 install -U git+ssh://git#dsghe.<mydomain>/bshelton/package_test.git#master#egg=featurestore
from featurestore.featurestore import *

Python: how to edit an installed package?

I installed some package via pip install something. I want to edit the source code for the package something. Where is it (on ubuntu 12.04) and how do I make it reload each time I edit the source code and run it?
Currently I am editing the source code, and then running python setup.py again and again, which turns out to be quite a hassle.
You should never edit an installed package. Instead, install a forked version of package.
If you need to edit the code frequently, DO NOT install the package via pip install something and edit the code in '.../site_packages/...'
Instead, put the source code under a development directory, and install it with
$ python setup.py develop
or
$ pip install -e path/to/SomePackage
Or use a vcs at the first place
$ pip install -e git+https://github.com/lakshmivyas/hyde.git#egg=hyde
Put your changes in a version control system, and tell pip to install it explicitly.
Reference:
Edit mode
You can edit the files installed in /usr/local/lib/python2.7/dist-packages/. Do note that you will have to use sudo or become root.
The better option would be to use virtual environment for your development. Then you can edit the files installed with your permissions inside your virtual environment and only affect the current project.
In this case the files are in ./venv/lib/pythonX.Y/site-packages
The path could be dist-packages or site-packages, you can read more in the answer to this question
Note that, as the rest of the people have mentioned, this should only be used sparingly, for small tests or debug, and being sure to revert your changes to prevent issues when upgrading the package.
To properly apply a change to the package (a fix or a new feature) go for the options described in other answers to contribute to the repo or fork it.
I too needed to change some things inside a package. Taking inspiration from the previous answers, You can do the following.
Fork the package/repo to your GitHub
clone your forked version and create a new branch of your choice
make changes and push code to the new branch on your repository
you can easily use pip install -e git+repositoryurl#branchname
There are certain things to consider if its a private repository
If you are doing the custom module that you want hot loading, you can put your running code also inside the module. Then you can use python -m package.your_running_code. In this way, you can change the module in the package and reflect the result of your running code immediately.

Something goes wrong when adding jedi-vim

I followed mbrochh's instruction https://github.com/mbrochh/vim-as-a-python-ide to build my vim as a python IDE. But things go wrong when openning the vim after I put jedi-vim into ~/.vim/bundle. The following is the warnings
Error detected while processing CursorMovedI Auto commands for "buffer=1":
Traceback (most recent call last)
Error detected while processing CursorMovedI Auto commands for "buffer=1":
File "string", line 1, in module
Error detected while processing CursorMovedI Auto commands for "buffer=1":
NameError: name 'jedi_vim' is not defined
I hope someone can figure out the problem and thanks for your help.
If you’re trying to use Vundle to install the jedi-vim plugin, I don’t think you should have to place it under ~/.vim/bundle. Instead, make sure you have Vundle set up correctly, as described in its “Quick start”, and then try adding this line to your ~/.vimrc after the lines where Vundle is set up:
Plugin 'davidhalter/jedi-vim'
Then run :PluginInstall and the plugin should be installed.
make sure that you have install jedi,
I solved my problem with below command..
cd ~/.vim/bundle/jedi-vim
git submodule update --init
(Using ubuntu 14.04LTS with Python 2.7)
I had a very similar issue and I found that I needed to integrate Jedi into my Python installation.
I did the following...
sudo apt-get install python-pip
sudo pip install jedi
Then if you haven't done so already, you can then add Jedi to VIM via Pathogen as follows...
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -so ~/.vim/autoload/pathogen.vim https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim
Then... add this line to your '~/.vimrc' file (Create it if it doesn't already exist.)
call pathogen#infect()
Then Save and Quit.
Lastly...
cd ~/.vim/bundle
git clone git://github.com/davidhalter/jedi-vim.git
That's it.
Dependencies exists in the Jedi git repo. I expect you are using pathogen as extension manager. Use git clone with --recursive option.
cd ~/.vim/bundle/ && git clone --recursive https://github.com/davidhalter/jedi-vim.git
Dave Halter has this instruction in the docs on github.
BTW, this is common behavior for all vim extensions with dependencies, such as flake8-vim. Furthermore if you just cloned any repo, which has dependencies, not recursively, you can have very unexpected issues. So this question in a greater extent about git recursive cloning and git submodules.

Errors when running vim with the pyflakes plugin

I'm playing with the pyflakes plugin for vim and now when I open a python file I get the error messages in the screenshot here
Any ideas how to fix this?
Thanks in advance...
https://github.com/kevinw/pyflakes-vim/issues/27
You can recommend to users that they clone the pyflakes-vim repo with git clone --recursive or you can suggest after the fact to use git submodule update --init --recursive if pyflakes-vim is saved as a git submodule itself.
Or go to pyflakes-vim and:
git submodule init && git submodule update
The point is that pyflakes-vim needs a (fresh) local copy of pyflakes under ftplugin/plugin/pyflakes if the system-wide installed version is too old.
Could be an issue with the version of Python you're running under vs. what the package you're using is looking for. A quick google for "Module getChildNodes python" got me to the page for Python compiler package which has one of those nice little "Deprecated" messages on it. So it might be that the pyflakes plugin is out of synch with the version of Python you have installed. "Python -V" will show you what version you're running.
C:\projects\fun>python -V
Python 2.7.1
I tried this to solve my problem under the Mac OS X 10.9.5.
sudo easy_install pip
pip install pyflakes
Then I opened the python scripts again, no issues reported as this:
Enjoy!
Robin
2015.01.30
This is a bug in pyflakes and we cannot help you with this here.
Try filing an issue on their git repository.

Categories

Resources