- No module named xxxxxx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xxxxxx
**解决方法:**
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages')
from PIL import Image
***
2. 安装第三方库,超时报错--Read timed out.
**设置超时时间即可**
pip --default-timeout=100 install -U Pillow
示例代码为安装 “Pillow”
[详细请点击这里](http://www.cnblogs.com/xiaoduc-org/p/5958973.html)
***
3. macOS 使用 pyenv 安装python 出现 "The Python zlib extension was not compiled ..."错误
xcode-select --install
[详细请点击这里](http://stackoverflow.com/questions/34200602/the-python-zlib-extension-was-not-compiled-on-mac-os-x-10-11-1)
---
4. TypeError: 'module' object is not callable
程序代码
class Person:
#constructor
def init(self,name,sex):
self.Name = name
self.Sex = sex
def ToString(self):
return 'Name:'+self.Name+',Sex:'+self.Sex
报错输出
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
per = Person('dnawo','man')
TypeError: 'module' object is not callable
**原因分析:**
Python导入模块的方法有两种:import module 和 from module import,区别是前者所有导入的东西使用时需加上模块名的限定,而后者不要。
**正确的代码:**
person = Person.Person('dnawo','man')
[参考文章](http://www.cnblogs.com/kungfupanda/archive/2012/08/09/2630784.html)
---
网友评论