我正在尝试在Linux Mint 17上安装一个名为ciscoconfparse的python模块。当我使用python 2的pip安装它时,当我尝试导入时,一切正常,但是当我尝试使用pip3时(Python 3.4) ,模块显示在安装目录中,但我无法导入它的任何部分。
我可以在这里找到模块
/usr/local/lib/python3.4/dist-packages/ciscoconfparse-1.1.1-py3.4.egg/ciscoconfparse
在这个目录里面是ciscoconfparse.py文件,它有CiscoConfParse类,但我不能用
导入它from ciscoconfparse import CiscoConfParse
当我尝试安装时,看起来有一些问题,但仍然说已经安装完成。
~/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...
在作者网站上,他说它已经过测试,可用于Python> 3.2。我正在使用Pycharm作为ide。到目前为止,我似乎可以使用python3的虚拟环境,看看是否有任何改变,或者我可以将模块放入我正在制作的模块中。是否有任何原因安装可能无法正常工作?或者,将模块包含在我自己的项目中的最佳方法是什么?
答案 0 :(得分:1)
由于相对导入损坏,安装可能无法正常工作吗?或者,将模块包含在我自己的项目中的最佳方法是什么?
ciscoconfparse版本1.1.1在所有Python3版本中失败。
由于ciscoconfparse
版本1.1.1(以及之前)PEP 366不合规导致相对导入失败;要解决此问题,ciscoconfparse在包中添加了__main__.py
。我手动测试了Python2.7和Python3.4.1;据我所知,版本1.1.2修复了Python3的问题。
答案 1 :(得分:1)
我遇到了同样的问题,但已在最新版本1.1.3 https://pypi.python.org/pypi/ciscoconfparse/1.1.3上修复。请试试。