Installing jedi-vim fails: vim says wrongly that +python is not compiled - python

I am trying to install jedi-vim. I am doing this at work - so I have to use gVim in Windows. I have already read several other posts in this forum. This has somehow made me smarter but still does not solve my problem.
I did the following things:
installed Pathogen
cloned jedi vim from https://github.com/davidhalter/jedi-vim.git and copied it to the bundle/ folder in the vim-dir.
Now, when I open a *.py-file vim always tells me
jedi-vim requires vim compiled with +python
but ':version' tells me that it's compiled with +python/dyn and +python3/dyn.
So what is the problem?
Additional infos:
vim version: 7.4
When I use ctrl+space to autocomplete a python key word, it tells me:
Error detected while processing function jedi#completions: line 1: E492: Not an editor command: Python jedi_vim.completions()
Error detected while processing function jedi#completions: line 1: E492: Not an editor command: Python jedi_vim.completions()
Press ENTER or type command to continue

I'm not sure if your are still experiencing the same issue, but after looking around I found this blog post that solved the problem for me. Essentially, it's just about re-installing vim (don't delete any config files) and then reinstalling from the source at the vim mercurial repo with the right flags. There might be a shorter/simpler version of doing this, but after trying back and forth many solutions, this one was the only one that worked:
Compiling Vim with Python and Ruby support on Ubuntu
These are the steps:
Check if Vim is compiled with Python:
$ vim --version | ack '(python)'
Remove Vim version installed:
$ sudo apt-get remove vim-common vim-runtime
Install dependencies needed to compile Vim:
$ sudo apt-get build-dep vim
Clone Vim repository, compile it and install the new version:
$ hg clone https://vim.googlecode.com/hg/ vim
$ cd vim
$ ./configure --enable-pythoninterp
$ make
$ sudo make install

+python/dyn means that Python support isn't statically compiled it, it's loaded dynamically when needed at runtime.
This is described in the python-dynamic help section:
On MS-Windows the Python library can be loaded dynamically. The |:version| output then includes |+python/dyn|.
This means that Vim will search for the Python DLL file only when needed.
When you don't use the Python interface you don't need it, thus you can use
Vim without this DLL file.
To use the Python interface the Python DLL must be in your search path. In a console window type "path" to see what directories are used.
The name of the DLL must match the Python version Vim was compiled with.
Currently the name is "python24.dll". That is for Python 2.4. To know for
sure edit "gvim.exe" and search for "python\d*.dll\c".
(Don't worry about the 2.4 there; I just happened to find docs from a few years ago. Read the help in your own copy of vim—or, better, do what the last paragraph says.)
So, either you don't have Python, you have the wrong version of Python, it's not on your %PATH%, vim is searching for it incorrectly, or it's failing to load.

At that time the problem was another one. I mixed up the architectures for vim and python - I used vim64Bit, but pyhton for 32bit.
I repaired that already some time ago but the other day I had to restart my computer and do some microsoft-Updates.
Unfortunately my vim (7.4) was totally broken. I had to re-set my home-dir. Then at least my vimrc was accessible again, but still my jedi in vim does not work.
Python is available in vim but still jedi does not seem to load correctly.
When I type "len(" in the beginning of a .py-file, at the place where arguments should be explained there are some strange characters, similar to this:
==jedi=0, == (_object_*) ==jedi==
When I type "self.", it says "unknown function: pythoncomplete#Complete"
I think it's only a configuration-issue, because it worked before the reboot.
Jedi is installed systemwide (with pip). If I try to install it "again", pip says that jedi is already installed.
I would appreciate your help very much ;-)

Related

Is there a way to rebuild python on Ubuntu 14.04?

Some downloads are failing due to Python not being built with the --enable-shared tag, is there some way to get rid of the version I have and rebuild python? Or even better, just change it without reinstalling?
You can rebuild python, and pass --enable-shared to ./configure
Just follow:
For python 3:
https://docs.python.org/3/using/unix.html#building-python
For Python 2:
https://docs.python.org/2/using/unix.html#building-python
Be careful with the things in your distribution that require python, make sure you set the Python Path properly. And check if any of them requires any special configuration flags.
You can install different Python versions (side-by-side even) using pythonz: http://saghul.github.io/pythonz/
Basically, after installing it, you run a command to download and install Python with the version you want:
pythonz install 3.5.1
To pass custom compiling options, use --configure "... options here" as per documentation here.
It even supports PyPy and Jython.
I've been using it with success for the past year or so, it has made my life of testing projects in different Python versions much easier -- highly recommended.
Get sources with:
apt-get source python2.7
in the downloaded directory, change in python2.7.../debian/rules:
with_interp := static
#with_interp := shared
to
#with_interp := static
with_interp := shared
Then at the same level as the debian directory, run dpkg-buildpackage. You'll get ready .deb packages one directory higher. Just install them with dpkg -i python2.7.....deb

Vim compiled with Python support but can't see sys version

I compiled the development version of Vim with both Python 2 and Python 3 support. The output of vim --version has +python/dyn and +python3/dyn in it. I ran the configure file with
g
./configure --enable-pythoninterp --enable-python3interp --with-python-config-dir=/usr/lib64/python2.7/config --with-python3-config-dir=/usr/lib64/python3.3/config --with-x --with-features=huge
However when I run :python import sys; print(sys.version) I get
E448: Could not load library function _PyArg_Parse_SizeT
E263: Sorry, this command is disabled, the Python library could not be loaded.
Why would this be? I found out because of YouCompleteMe stating that it requires Vim compiled with 2.x support.
Thanks
I had a similar issue on my Debian box. If you're using a Debian-based system, you will not be able to load both Python libraries simultaneously. That's why when you set --enable-python-interp and --enable-python3-interp they always load with the /dyn suffix.
If your vim plugins don't need both versions, you should just pick one of the versions and stick with it. The links below provide more info.
Explained by Debian maintainer
Vim Python Support
P.S. - In case you tried this on Windows as well, loading either Python version will work, so the /dyn isn't an issue there.

Python support missing

I installed vim from source according to this link and it was succesful. But there is no python- support. I have installed python-dev and I've looked for the directory the Python config-file is in to set the right flag:
--with-python-config-dir=/usr/lib/python2.7-config
--enable-pythoninterp
I've installed vim from source two times, because the first time I forgot sth.
How can I get python-support now?
The installation guide you showed also states
You may need to add --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ to the configure call.
Have you tried this?
FYI, this is the contents of the directory on my Debian jessie (aka testing) x86_64.
$ ls /usr/lib/python2.7/config-x86_64-linux-gnu
Makefile Setup Setup.config Setup.local config.c config.c.in
install-sh* libpython2.7-pic.a libpython2.7.a libpython2.7.so# makesetup* python.o

Basic Vim Installation, from Source Code

Tried installing Vim 7.3 so I first installed Mercurial, which allowed me to clone vim source code off Googlecode. This was done successfully.
Problem started from here:
cd vim/src
./configure --enable-pythoninterp --with-features=huge -prefix=$HOME/opt/vim
which drew this response from the terminal:
configure: loading cache auto/config.cache
checking whether make sets $(MAKE)... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/JayEdge/vim/src':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
Tried looking at config.log (in my case it was auto/config.log) but I'm not sure what to look out for.
Background: I've checked that Xcode is installed properly, and gcc.vim was found inside the route vim/runtime/compiler. Should I move this (or duplicate this) into another folder? If so, which folder to move it into?
Like Karoly said, you need a c compiler. Since it looks like you are running OSX (based on your xcode comment I would suggest grabbing the OSX-GCC installer at the following site:
https://github.com/kennethreitz/osx-gcc-installer
I would also look into grabbing homebrew for installing things like vim.
Cheers,
Sean
no acceptable C compiler found in $PATH
That's a pretty clear error message, you need to install a compiler, if you haven't done sone.
Install gcc.
If you already installed gcc you have to add the path so configure can find it, eg:
export PATH="$PATH:/usr/bin"
Problem has been solved and here's to share with anyone if they have the same problems, specifically for people who install xCode via the app store after March 2012. (Credits to my Python Mentor, Martin)
Xcode from the app store currently only allows you to download the IDE, which is not what we want. What we want is the Apple Developer Tools, which you can get via https://developer.apple.com/xcode/ after signing up as a Apple Developer. Search for "Command Line Tools, late March 2012", install it and the configure command earlier should work properly.
Otherwise, you may refer to Sean's answer earlier.
FYI, I do intend to install homebrew but as a beginner, compiling it from source code is a great way of picking up some basics, interact with some basic syntax (or learn to parse them).
you can try it:
yum install gcc

how to install pycairo for python 3 on Ubuntu 10.04

i am trying to install pycairo 1.10.0 for use with my custom-build python 3.1. however,
sudo /flower/bin/easy_install-3.1 pycairo
fails with
XXX#XXXX:/adventures$ sudo /flower/bin/easy_install-3.1 pycairo
install_dir /flower/lib/python3.1/site-packages/
Searching for pycairo
Reading http://pypi.python.org/simple/pycairo/
Reading http://cairographics.org/pycairo
Best match: pycairo 1.10.0
Downloading http://cairographics.org/releases/pycairo-1.10.0.tar.bz2
Processing pycairo-1.10.0.tar.bz2
error: Couldn't find a setup script in /tmp/easy_install-zeG9HB/pycairo-1.10.0.tar.bz2
and indeed, there is no setup.py in the said download; instead, the INSTALL says:
Install Procedure
-----------------
$ ./waf --help # shows available waf options
$ ./waf configure # use --prefix and --libdir if necessary
# --prefix=/usr --libdir=/usr/lib64 for Fedora 64-bit
$ ./waf build
$ ./waf install
Use
$ python3 ./waf ...
if you have python2 and python3 installed, and the default is python 2.
Testing
-------
See test/README
i understand that as telling me that i should
sudo /flower/bin/python3.1 ./waf configure --prefix=/flower/pycairo/
or similar; however, this leads to the following error:
./options()
Setting top to : /tmp/pycairo-1.10.0
Setting out to : /tmp/pycairo-1.10.0/build_directory
./configure()
Checking for 'gcc' (c compiler) : ok
Checking for program python : /usr/bin/python
python executable '/usr/bin/python' different from sys.executable '/flower/bin/python3.1'
Checking for python version : (2, 6, 5, 'final', 0)
The python version is too old, expecting (3, 1, 0)
so i went down into the source code; there is seemingly no way to tell this waf thingie that the targetted python version is simply the one it runs on itself, so i fumbled around and got as far as this:
Checking for 'gcc' (c compiler) : ok
Checking for program python : /usr/bin/python
#############293 /flower/bin/python3.1
Checking for python version : (3, 1, 2, 'final', 0)
Checking for library python3.1 in LIBDIR : yes
Checking for program python3.1-config : not found
Checking for program python-config-3.1 : not found
Checking for header Python.h : Could not find the python development headers
Checking for [] : not found
The configuration failed
i do in fact have a file /flower/bin/python3.1-config so i don't get it. the python code that does all this is rather hard to handle.
any suggestions how to go on? is there a *.deb or similar ready for pycairo + python 3? couldn't find any.
By looking at the python.py file in that subdir I decided to try setting an environment var before executing the waf thru python3:
export PYTHON="python3"
And then the install mysteriously succeeded...
I'm using Ubuntu Karmic, but installing with python2.7 compiled from source, so this is a work around I found in my case. I though it might be helpful, but please use caution.
I found some discussion threads that has similar installation problems here
Although it's not the same python version, there are some flags which you can set for waf.
I got past that Python.h part after using the following command
LDFLAGS="-lm -ldl -lutil" ./waf configure
As I have compiled from source python2.7, I need to reroute the paths with CFLAGS.
The final command looks like this:
CFLAGS="-l/usr/local/include/python2.7 -l/usr/local/bin" LDFLAGS="-lm -ldl -lutil" ./waf configure
I have no idea how the LDFLAGS work, so use with caution.
Alternatively (dangerous method), if you don't want to set the CFLAGS, I did do some symbolic-re-linking in the /local/bin of python to my python2.7, same with python-config to python2.7-config (if you installed from package manager, you might not need to do this)
This is clearly a bug in the pycairo installer, where it tries to figure out where the Python exe is (when what it should do is to simply use the Python exe that it is run with).
I tried to find it, but this code is using its own completely custom build system (it's not onvious why) and the code is laid out in a very weird way, astonishingly with major parts of the code hidden(!) in a directory called .waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6 and written in some of the most unreadable Python code I've ever seen. As such it would take me hours to understand this code and help you with what probably is a trivial bug.
If you really need this library I suggest you contact the author and ask him nicely if he can fix the bug.

Categories

Resources