0

I'm running Arch Linux and I have the vim-latexsuite package installed. A while ago I noticed started getting an error whenever I opened a .tex file:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/share/vim/vimfiles/ftplugin/latex-suite/bibtools.py", line 11, in <module>
    from urllib import urlopen, pathname2url
ImportError: cannot import name 'urlopen' from 'urllib' (/home/tomas/miniconda3/lib/python3.7/urllib/__init__.py)

So basically this error is coming up (I think) because vim-latexsuite is using python 3, but it's trying to import a module that only exists in Python 2.

However, when I modify its code to use the Python 3 version I get this error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/share/vim/vimfiles/ftplugin/latex-suite/bibtools.py", line 11, in <module>                                                                                     
    from urllib.request import urlopen, pathname2url
  File "/home/me/miniconda3/lib/python3.7/urllib/request.py", line 84, in <module>
    import base64
  File "/home/me/miniconda3/lib/python3.7/base64.py", line 10, in <module>
    import struct
  File "/home/me/miniconda3/lib/python3.7/struct.py", line 13, in <module>
    from _struct import *

Which seems like it's related to my miniconda install, but I can't pinpoint the problem. If I open Python 3 and try from urllib.request import urlopen, pathname2url, it works fine, so it's hard for me to debug it.

Any ideas of how to solve this?

  • could be that archlinux has python as a default pointing to python 3, whereas in other systems python defaults to python 2. You can try to check that using virvualenv2 to launch vim in a context where python 2 is the default and see whether the error is still there. – Vincent Nivoliers May 6 '19 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.