Something goes wrong when adding jedi-vim - python

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.

Related

How do I run this python script?

I'm new to python, and I was wondering if you could help me run a python script. I'm trying to run a script called PunchBox from Github: https://github.com/psav/punchbox. So far, I have Python 3.9.5 and Git Bash.
In the GitHub page, it says:
To install, clone the repo, cd into it and then execute the following:
virtualenv -p python2 .pb2
source .pb2/bin/activate
pip install -U pip
pip install .
What does this mean exactly? Where do I run this code?
So far, I tried downloading the zip file from GitHub, installing Python 3.5.9, using cmd, finding the directory with cd, and running that code; but got an error:
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name punchbox was given, but was not able to be found.
error in punchbox setup command: Error parsing C:\Users\Mi\Downloads\punchbox-master\punchbox-master\setup.cfg: Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name punchbox was given, but was not able to be found.
There's also a requirements.txt that lists additional scripts needed:
pre-commit
click
mido
pbr
PyYAML
svgwrite
Do these install automatically upon running the script for the first time?
I'm a little confused why I'm getting an error. Do you know what I'm doing wrong?
Thank you so much!
Giovanni
I assume you are new to programming. You have to write these lines in a terminal.
On Windows, it is Command Prompt or PowerShell Applications (latter preferred). On macOS, it is terminal
Copy all these lines at once, and paste them to your preferred terminal. The terminal will automatically run these one after the another.
FYI: Venv is a python package to create a virtual environment. The preceding commands set up the environment. Now install the required dependencies using this command instead of the last command (pip install .)
pip install -r requirements.txt
Based on your comment, it looks like you don't have virtualenv installed in your system. You may install it using the command pip install virtualenv.
Now, as you are using a Windows machine, you may open a Command Prompt or Windows PowerShell window and navigate to the directory where your cloned project resides.
Now, execute the following commands.
virtualenv -p python2 .pb2
.pb2\Scripts\activate.bat
pip install -U pip
pip install -r requirements.txt
Once you are done working in your virtual environment (which is named .pb2), you may close it by executing deactivate command.
#Giovanni T.
See, as far as you have installed Python and also downloaded the GitHub Repository as a zip file.
pip install -r requirements.txt
Just run this command.
Please make sure that the directory is pointing to the folder where this requirements.txt file is stored.

YouCompleteMe post install error : cannot import name _compare_digest

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 :)

Python grpc protobuf stubs generation issue: --grpc_out: protoc-gen-grpc: Plugin failed with status code 1

As the question says, I compiled grpc from source and also did sudo pip install grpcio, however, the which grpc_python_plugin doesn't return anything. This is a problem because the grpc python example for route_guide requires me to run protoc -I . --python_out=. --grpc_out=. --plugin=protoc-gen-grpc='which grpc_python_plugin' ./route_guide.proto
in order to generate the python stubs. Since, which grpc_python_plugin doesn't return anything, I get the following error:
: program not found or is not executable
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.
If I shorten the command I'm trying to run to:protoc -I . --python_out=. ./route_guide.proto, it generates the route_guide_pb2.py file but without the Servicer and Stub classes, and server and stub methods. Ofc, these methods are necessary if one wants to use grpc for any purpose. Any help would be appreciated.
python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. my_proto.proto
Edited:
Apparently, there is open Issue on gRPC github site regarding this problem. Protoc seems to have a compatibility issue with grpc_python_plugin? I solved this problem by installing grpc_tools, then used grpc_tools.protoc instead of protoc.
$ pip install grpcio-tools
$ pip install googleapis-common-protos
Useful python tutorial: https://grpc.io/docs/tutorials/basic/python.html
See Protoc Issues [791 and 4961]:
https://github.com/google/protobuf/issues/791
https://github.com/grpc/grpc/issues/4961
To resolve this error make sure you have grpc_python_plugin installed on your system.
On python platforms pip install grpcio doesn't install platform specific plugins, so you have to install them separately by taking following steps
a) cd grpc (grpc repository)
b) git submodule update --init
c) make grpc_python_plugin
This will build the grpc python plugin for you. Now, find out the location of grpc_python_plugin on your system, lets call it binary_path
If binary_path is under $PATH environment variable (echo $PATH), you are good to go. However, if it is not under $PATH variable, you have two options
Update run_codegen.sh to --plugin=protoc-gen-grpc=binary_path
or, copy the binary to one of the locations tracked by $PATH environment variable
It sounds like you don't have /usr/local/bin in your PATH; make install uses a prefix of /usr/local by default. Alternatively, after compilation grpc_python_plugin should be in bins/opt/.
the python's gRPC plugin for protoc is not installed by default
$ protoc -I=grpc/protos helloworld.proto --plugin=grpc_python_plugin --python_out=grpc/helloworld --grpc_python_out=grpc/helloworld
protoc-gen-grpc_pythong is not recognized as an internal or external command,
operable program or batch file.
--grpc_python_out: protoc-gen-grpc_python: Plugin failed with status code 1.
install protoc-gen-grpclib_python and protoc-gen-python_grpc
$ pip install grpclib protobuf
generate your python gRPC stubs (replace --grpc_python_out with --grpclib_python_out)
$ protoc -I=grpc/protos helloworld.proto --plugin=grpc_python_plugin --python_out=grpc/helloworld --grpclib_python_out=grpc/helloworld
https://github.com/grpc/grpc/issues/15675
I got a similar problem (which grpc_cpp_plugin was empty). In my case the problem was that I didn't have installed grpc and I solved this for my OS X with brew install grpc.

How can I install from a git subdirectory with pip?

I have a git repository with many folders, one of them being a python module installable with pip, like this:
repo.git/
repo.git/folder1/
repo.git/folder2/
repo.git/mymodule/
repo.git/mymodule/__init__.py
repo.git/mymodule/setup.py
repo.git/mymodule/...
Right now I have to do the following to install:
git clone http://server/repo.git
cd repo
pip install mymodule
cd ..
rm -rf repo
Is it possible to install the module directly with pip without explicitly cloning ?
I tried:
pip install git+https://server/repo.git/mymodule/
pip install git+https://server/repo.git:mymodule/
But I get:
IOError: [Errno 2] No such file or directory: '/tmp/pip-88tlLm-build/setup.py'
There is a pull request regarding this feature, and it seems to have been merged to develop branch a month ago. The syntax is the following:
pip install -e git+https://git.repo/some_repo.git#egg=version_subpkg&subdirectory=repo # install a python package from a repo subdirectory
We probably have to wait for a while until it gets merged to master and is distributed.
UPDATE: This is now available and documented at https://pip.pypa.io/en/stable/cli/pip_install/#vcs-support as follows:
For projects where setup.py is not in the root of project,
"subdirectory" component is used. Value of "subdirectory" component
should be a path starting from root of the project to where setup.py
is located.
So if your repository layout is:
- pkg_dir/
- setup.py # setup.py for package ``pkg``
- some_module.py
- other_dir/
- some_file
- some_other_file
You'll need to use
pip install -e vcs+protocol://repo_url/#egg=pkg&subdirectory=pkg_dir
Note: On Windows, you must place the URL in double quotes, or you'll get an error "'subdirectory' is not recognized as an internal or external command". E.g., use:
pip install -e "vcs+protocol://repo_url#egg=pkg&subdirectory=pkg_dir"
It's been already stated in one of the comments under the correct answer, but just to highlight this issue: when executing this from Linux command line, you must escape the &-character since ampersand is telling the command line to run a command in background:
git+https://git.repo/some_repo.git#egg=version_subpkg\&subdirectory=repo
Notice the backslash before the ampersand. The escaping behaviour might depend on the Linux distro; I'm not an expert.
If you ignore this, you might run into a cryptic error like the following:
bash: (...) command not found

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