ciscoconfparse in Python 3.4 module doesn't import correctly

北城余情 提交于 2019-12-13 00:49:24

问题


I'm trying to install a python module called ciscoconfparse on Linux Mint 17. When I install it with pip with python 2, all works well when I try to import, but when I try it with pip3 (for Python 3.4), the module shows up in the install directory, but I can't import any parts of it.

I can find the module here

/usr/local/lib/python3.4/dist-packages/ciscoconfparse-1.1.1-py3.4.egg/ciscoconfparse

Inside this directory is the ciscoconfparse.py file, which has the CiscoConfParse class, but I can't import it with

from ciscoconfparse import CiscoConfParse

When I try to install, it looks like there is a few problems, but still says it has sucessfuly installed.

~/Downloads/ciscoconfparse-1.1.1 $ sudo pip3 install ciscoconfparse
Downloading/unpacking ciscoconfparse
  Downloading ciscoconfparse-1.1.1.tar.gz (76kB): 76kB downloaded
  Running setup.py (path:/tmp/pip_build_root/ciscoconfparse/setup.py) egg_info for package ciscoconfparse
    zip_safe flag not set; analyzing archive contents...

    Installed /tmp/pip_build_root/ciscoconfparse/setuptools_hg-0.4-py3.4.egg

    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.orig' found under directory '*'
    warning: no previously-included files matching 'BUILD.ME' found under directory '*'
    warning: no previously-included files matching 'BITBUCKET_HG' found under directory '*'
    warning: no previously-included files matching '.hgrc' found under directory '*'
    warning: no previously-included files matching '*' found under directory '.hg'
    warning: no previously-included files matching '*' found under directory 'sphinx-doc'
Installing collected packages: ciscoconfparse
  Running setup.py install for ciscoconfparse

    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.orig' found under directory '*'
    warning: no previously-included files matching 'BUILD.ME' found under directory '*'
    warning: no previously-included files matching 'BITBUCKET_HG' found under directory '*'
    warning: no previously-included files matching '.hgrc' found under directory '*'
    warning: no previously-included files matching '*' found under directory '.hg'
    warning: no previously-included files matching '*' found under directory 'sphinx-doc'
      File "/usr/local/lib/python3.4/dist-packages/ciscoconfparse/excldiff_test.py", line 31
        print diffs
                  ^
    SyntaxError: invalid syntax

Successfully installed ciscoconfparse
Cleaning up...

On the authors site, he says that it has been tested to work on Python > 3.2. I'm using Pycharm as an ide. So far it seems like I can either use a virtual environment with python3 and see if that changes anything, or I can drop the module into the module I'm making. Is there any reason the install may not be working? Or else what is the best way to include the module with my own project?


回答1:


Is there any reason the install may not be working? Or else what is the best way to include the module with my own project?

ciscoconfparse version 1.1.1 failed in all Python3 versions due to broken relative imports.

Relative imports broke due to lack of compliance with PEP 366 in ciscoconfparse version 1.1.1 (and prior); to resolve this, ciscoconfparse added a __main__.py in the package. I manually tested this against Python2.7 and Python3.4.1; as far as I can tell, version 1.1.2 fixes the issues with Python3.




回答2:


I had the same issue but it has been fixed on the latest version 1.1.3, https://pypi.python.org/pypi/ciscoconfparse/1.1.3. Please try that.



来源:https://stackoverflow.com/questions/23997149/ciscoconfparse-in-python-3-4-module-doesnt-import-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!