Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,我想知道你是怎么解决这个问题的"cannot import name util" #22

Open
rayn316 opened this issue Jan 11, 2018 · 11 comments

Comments

@rayn316
Copy link

rayn316 commented Jan 11, 2018

环境:CentOS 7.4 + python2.7.5
错误:
Request Method: GET
Request URL: http://192.168.174.162:11289/
Django Version: 1.8.17
Exception Type: ImportError
Exception Value: cannot import name util
Exception Location: /usr/lib/python2.7/site-packages/paramiko/transport.py in , line 37
Python Executable: /usr/bin/python

@welliamcao
Copy link
Owner

paramiko没安装正确吗?easy_install paramiko 试一试?

@rayn316
Copy link
Author

rayn316 commented Jan 11, 2018

安装的
[root@localhost VManagePlatform]# easy_install paramiko
Searching for paramiko
Best match: paramiko 2.4.0
Adding paramiko 2.4.0 to easy-install.pth file

Using /usr/lib/python2.7/site-packages
Processing dependencies for paramiko
Finished processing dependencies for paramiko

@welliamcao
Copy link
Owner

pip install -r requirements.txt 这一步有错误或者警告吗?

@rayn316
Copy link
Author

rayn316 commented Jan 11, 2018

全部正确的(Requirement already satisfied),没有错误或者警告

@rayn316
Copy link
Author

rayn316 commented Jan 11, 2018

我看见这个文件/usr/lib/python2.7/site-packages/paramiko/transport.py是循环调用自己
错误地方内容:from paramiko import util

@welliamcao
Copy link
Owner

提供一下paramiko的版本信息?

@rayn316
Copy link
Author

rayn316 commented Jan 11, 2018

paramiko (2.4.0)

@rayn316
Copy link
Author

rayn316 commented Jan 11, 2018

我不知道是不是数据库的问题,我用的是mariadb,ovs版本是2.7

@welliamcao
Copy link
Owner

python -c "import paramiko;from paramiko import util;print paramiko.__version__"
你执行这个命令看看会不会报错,如果报错你换成 easy_install paramiko==2.2.1看看

@rayn316
Copy link
Author

rayn316 commented Jan 11, 2018

好吧。。。我重新来了一遍
发现命令python manage.py migrate出现以下错误

  1. 需要安装numpy模块
    解决办法: pip install numpy
  2. /usr/lib64/python2.7/site-packages/django/db/backends/mysql/base.py:124: Warning: Incorrect string value: '\xE8\x99\x9A\xE6\x8B\x9F...' for column 'name' at row 1
    解决办法: 我多执行几次之后就好了,好了。。。

之后访问web,之后错误是ssh_gss.py文件:
gssapi 'module' object has no attribute 'GSSException'
我参照网上解决办法:yum install -y python-paramiko
解决了之后再访问web
是paramiko/transport. in , line 37.
cannot import name util

使用命令
python -c "import paramiko;from paramiko import util;print paramiko.__version__"
没有报错,结果为2.1.1

https://stackoverflow.com/questions/29378234/python-import-paramiko-error-cannot-import-name-util
依照此链接所说方法
注释掉 from paramiko import util 再将 util 替换成 paramiko.util 不修改源内容 paramiko.util
可以解决当前问题,但是修改了这个文件,还有下个文件,太多了

不知道还有什么办法

@rayn316
Copy link
Author

rayn316 commented Jan 11, 2018

paramiko.zip
我把这文件上传吧,paramiko.zip 可以解压到 /usr/lib/python2.7/site-packages/paramiko 目录下
终于可以看见界面了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants