枕头未在Pycharm中安装(Windows 10)-Python 3.8

时间:2020-04-23 14:48:17

标签: python python-3.x pip python-imaging-library

我一直在研究Python-Django项目,并且想在IDE(Pycharm)上安装Pillow以便使用ImageField。但是通过Pycharm设置安装Pillow时出现错误。

Settings -> Project Interpreter -> + -> Pillow

它说无法安装Pillow。然后我用谷歌搜索,发现很多人都遇到同样的问题。通过研究许多网站,我发现了许多安装Pillow和PIL的命令。我一一尝试,因为我想以某种方式解决它。但是结果是负面的,没有一个命令对我有用。我对解决这个问题的最后希望是这篇文章。我希望你们中的任何一个可以帮助我。我将在本文中获得的输出中包括我尝试过的每个命令,以使其更加清晰易懂。

Operating System : Windows 10 (64bit)
Python Version : 3.8
IDE : Pycharm Community Edition
Framework : Django

在下面,我将发布每条命令以及我尝试过的输出,它们是:

$ pip install Pillow

Output :

Command "C:\Users\user\PycharmProjects\DjangoBlog\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-v4
bi0ay9\\Pillow\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\user\AppData\Local\Temp\pip-record-iptbqeti\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\user\PycharmProjects\Django
Blog\venv\include\site\python3.8\Pillow" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-install-v4bi0ay9\Pillow\
$ pip install Pillow==6.2.1 --no-cache-dir

Output :

Command "C:\Users\user\PycharmProjects\DjangoBlog\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-f1
8bzk3e\\Pillow\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\user\AppData\Local\Temp\pip-record-_pf_lrfq\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\user\PycharmProjects\Django
Blog\venv\include\site\python3.8\Pillow" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-install-f18bzk3e\Pillow\
$ easy_install pillow

Output :

File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\command\easy_install.py", line 679, in easy_install
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\command\easy_install.py", line 705, in install_item
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\command\easy_install.py", line 890, in install_eggs
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\command\easy_install.py", line 1158, in build_and_install
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\command\easy_install.py", line 1144, in run_setup
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\sandbox.py", line 253, in run_setup
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\sandbox.py", line 195, in setup_context
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\sandbox.py", line 166, in save_modules
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\sandbox.py", line 141, in resume
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\_vendor\six.py", line 685, in reraise
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\sandbox.py", line 154, in save_modules
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\sandbox.py", line 195, in setup_context
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\sandbox.py", line 250, in run_setup
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg\setuptools\sandbox.py", line 45, in _execfile
  File "C:\Users\user\AppData\Local\Temp\easy_install-os0q5ljs\Pillow-7.1.1\setup.py", line 914, in <module>
setuptools.sandbox.UnpickleableException: RequiredDependencyException('\n\nThe headers or library files could not be found for zlib,\na required dependency when compiling P
illow from source.\n\nPlease see the install instructions at:\n   https://pillow.readthedocs.io/en/latest/installation.html\n\n')


$ pip install Pillow==7.1.1 --no-cache-dir

Output :

Command "C:\Users\user\PycharmProjects\DjangoBlog\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-kt
a4ax5z\\Pillow\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\user\AppData\Local\Temp\pip-record-raqit_rw\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\user\PycharmProjects\Django
Blog\venv\include\site\python3.8\Pillow" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-install-kta4ax5z\Pillow\
$ pip install image 

Output :

Command "C:\Users\user\PycharmProjects\DjangoBlog\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-c6
6pzbsp\\pillow\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\user\AppData\Local\Temp\pip-record-ccvx8hkl\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\user\PycharmProjects\Django
Blog\venv\include\site\python3.8\pillow" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-install-c66pzbsp\pillow\
$ pip install PIL

Output :

Could not find a version that satisfies the requirement PIL (from versions: )
No matching distribution found for PIL

我试图从一个“朋友系统”中复制“枕头”文件夹,然后将其放在“站点软件包”文件夹中。但是在运行时出现如下错误:

ile "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\core\management\base.py", line 392, in check
    all_issues = self._run_checks(
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\urls\resolvers.py", line 407, in check
    for pattern in self.url_patterns:
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\user\PycharmProjects\DjangoBlog\MyProject\MyProject\urls.py", line 6, in <module>
    from users import views as user_views
  File "C:\Users\user\PycharmProjects\DjangoBlog\MyProject\users\views.py", line 6, in <module>
    from PIL import Image
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\PIL\Image.py", line 93, in <module>
    from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\PIL\__init__.py)
$ python -m pip install --upgrade pip

Output :

Exception:
Traceback (most recent call last):
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\cli\base_command.py", line 179, in main
    status = self.run(options, args)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\commands\install.py", line 384, in run
    installed = install_given_reqs(
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\req\__init__.py", line 53, in install_given_reqs
    requirement.install(
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\req\req_install.py", line 910, in install
    self.move_wheel_files(
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\req\req_install.py", line 437, in move_wheel_files
    move_wheel_files(
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\wheel.py", line 544, in move_wheel_files
    generated.extend(maker.make(spec))
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 405, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 309, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 245, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\user\PycharmProjects\DjangoBlog\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 384, in _get_launcher
    result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
$ pip install --use-wheel Pillow

Output :

Usage:
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

no such option: --use-wheel

如果有人可以帮助我解决此问题,请帮助我。谢谢。

0 个答案:

没有答案