rfancn / aliyun-ddns-client

Python DDNS client for Aliyun
404 stars 137 forks source link

ImportError: No module named requests #23

Closed snowdream closed 6 years ago

snowdream commented 6 years ago

已经安装了requests和netifaces,为什么运行python ddns.py还提示错误。

snowdream$ cd /Users/snowdream/bin/aliyun-ddns-client && /usr/bin/python ddns.py
Traceback (most recent call last):
 File "ddns.py", line 20, in <module>
   from utils import DDNSUtils
 File "/Users/snowdream/bin/aliyun-ddns-client/utils.py", line 26, in <module>
   import requests
ImportError: No module named requests
snowdream$ pip install requests
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: requests in /usr/local/lib/python3.6/site-packages (2.18.4)
Requirement already satisfied: idna<2.7,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests) (2.6)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages (from requests) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests) (2018.4.16)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests) (1.22)
snowdream$ pip install netifaces
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: netifaces in /usr/local/lib/python3.6/site-packages (0.10.7)
 snowdream$ pip list
Package    Version  
---------- ---------
certifi    2018.4.16
chardet    3.0.4    
idna       2.6      
meson      0.45.0   
netifaces  0.10.7   
pip        10.0.1   
requests   2.18.4   
setuptools 38.5.1   
urllib3    1.22     
wheel      0.30.0   
rfancn commented 6 years ago

很可能你默认的python binary是python3, 请检查你的python -V

snowdream commented 6 years ago

@rfancn 是的,我的pc上有python2.7 和python3.6,默认是python3.6. 这个项目不支持python3吗?

rfancn commented 6 years ago

你默认的python binary很可能是python2

$ python -V
Python 2.7.5

但你用的pip的版本可能安装的是for python3的,所以你安装的requests库都是安装到python3的路径下去了,python2执行的时候自然提示找不到requests库

$ pip -V
pip 10.0.1 from /usr/lib/python3.6/site-packages/pip (python 3.6)

本项目支持python3, 但是你得显式的使用python3来执行,例如:

$python3.6 ddns.py