我在windows 7 32位上使用Pycharm,我正在学习使用django创建网站。我正在尝试制作imagefield,所以我尝试在命令窗口中安装Pillow,结果出现了以下错误:
(venv) C:UsersمرحباPycharmProjectsTryDjango>py -m pip install Pillow
Collecting Pillow
Exception:
Traceback (most recent call last):
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalbasecommand.py", line 228, in main
status = self.run(options, args)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalcommandsinstall.py", line 291, in run
resolver.resolve(requirement_set)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalresolve.py", line 103, in resolve
self._resolve_one(requirement_set, req)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalresolve.py", line 257, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalresolve.py", line 210, in _get_abstract_dist_for
self.require_hashes
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internaloperationsprepare.py", line 245, in
prepare_linked_requirement
req.populate_link(finder, upgrade_allowed, require_hashes)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalreqreq_install.py", line 307, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalindex.py", line 484, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalindex.py", line 442, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalindex.py", line 587, in _get_pages
page = self._get_page(location)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalindex.py", line 705, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internalindex.py", line 814, in get_page
"Cache-Control": "max-age=600",
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorrequestssessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internaldownload.py", line 397, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorrequestssessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorrequestssessions.py", line 658, in send
r.content
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorrequestsmodels.py", line 823, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorrequestsmodels.py", line 745, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorurllib3response.py", line 436, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorurllib3response.py", line 384, in read
data = self._fp.read(amt)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorcachecontrolfilewrapper.py", line 63, in read
self._close()
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorcachecontrolfilewrapper.py", line 50, in _close
self.__callback(self.__buf.getvalue())
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorcachecontrolcontroller.py", line 296, in cache_response
self.serializer.dumps(request, response, body=body),
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_internaldownload.py", line 298, in set
return super(SafeFileCache, self).set(*args, **kwargs)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorcachecontrolcachesfile_cache.py", line 113, in set
with self.lock_class(name) as lock:
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorlockfilemkdirlockfile.py", line 19, in __init__
LockBase.__init__(self, path, threaded, timeout)
File "C:UsersمرحباAppDataLocalProgramslibsite-
packagespip_vendorlockfile__init__.py", line 226, in __init__
self.tname = '-%x' % (ident & 0xffffffff)
TypeError: unsupported operand type(s) for &: 'method' and 'int'
事实上,我是初学者,请告诉我该怎么做,我正处于完成我的第一个网站的最后一步,我需要安装枕头,以便在我的模型中制作imagefield。你能帮帮我吗?
首先尝试以下操作-
pip install Pillow
如果以上方法不起作用,请尝试以下方法-
pip3 install Pillow
编辑1:
如果pip显示错误,请执行以下操作-
1( 检查您正在使用的python版本。最新版本是3.8。看看下面是否显示任何错误?
python3
如果上面的命令显示错误,则意味着您可能需要从其网站安装最新版本的python。
2( 检查pip版本-
pip -V
# pip 20.0.2 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)
python3 -m pip install --upgrade pip
上面应该安装lates-pip版本(20.0.2(。然后尝试用pip
安装Pillow
。