简体   繁体   中英

Cannot install Flask in PyCharm on MacBook

I am quite new to Python, so maybe this is something quite dumb. I tried to install the Flask module in PyCharm, first in the preference window, later in the python console (but the built in).

I am on a MacBook with the newest OS, using Python 3.9. The error message in the python console is the following:

$ pip3 install Flask    
Collecting Flask
  Using cached Flask-1.1.2-py2.py3-none-any.whl (94 kB)
Requirement already satisfied: click>=5.1 in ./venv/lib/python3.9/site-packages (from Flask) (7.1.2)
Collecting itsdangerous>=0.24
  Using cached itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting Jinja2>=2.10.1
  Using cached Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
Collecting MarkupSafe>=0.23
  Using cached MarkupSafe-1.1.1.tar.gz (19 kB)
Collecting Werkzeug>=0.15
  Using cached Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
Building wheels for collected packages: MarkupSafe
  Building wheel for MarkupSafe (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/path/to/folder/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py'"'"'; __file__='"'"'/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-wheel-inl8hwcr
       cwd: /private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/
  Complete output (79 lines):
  /usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'project_urls'
    warnings.warn(msg)
  /usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'python_requires'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-11-x86_64-3.9
  creating build/lib.macosx-11-x86_64-3.9/markupsafe
  copying src/markupsafe/_constants.py -> build/lib.macosx-11-x86_64-3.9/markupsafe
  copying src/markupsafe/__init__.py -> build/lib.macosx-11-x86_64-3.9/markupsafe
  copying src/markupsafe/_native.py -> build/lib.macosx-11-x86_64-3.9/markupsafe
  copying src/markupsafe/_compat.py -> build/lib.macosx-11-x86_64-3.9/markupsafe
  running egg_info
  writing src/MarkupSafe.egg-info/PKG-INFO
  writing dependency_links to src/MarkupSafe.egg-info/dependency_links.txt
  writing top-level names to src/MarkupSafe.egg-info/top_level.txt
  reading manifest file 'src/MarkupSafe.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  no previously-included directories found matching 'docs/_build'
  warning: no previously-included files matching '*.py[co]' found anywhere in distribution
  writing manifest file 'src/MarkupSafe.egg-info/SOURCES.txt'
  copying src/markupsafe/_speedups.c -> build/lib.macosx-11-x86_64-3.9/markupsafe
  running build_ext
  building 'markupsafe._speedups' extension
  creating build/temp.macosx-11-x86_64-3.9
  creating build/temp.macosx-11-x86_64-3.9/src
  creating build/temp.macosx-11-x86_64-3.9/src/markupsafe
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/Users//Users/path/to/folder/venv/include -I/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/markupsafe/_speedups.c -o build/temp.macosx-11-x86_64-3.9/src/markupsafe/_speedups.o
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py", line 105, in <module>
      run_setup(True)
    File "/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py", line 53, in run_setup
      setup(
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/Users//Users/path/to/folder/venv/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py", line 36, in run
      build_ext.run(self)
    File "/Users//Users/path/to/folder/venv/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 66, in run
      _build_ext.run(self)
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build_ext.py", line 340, in run
      self.build_extensions()
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build_ext.py", line 449, in build_extensions
      self._build_extensions_serial()
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build_ext.py", line 474, in _build_extensions_serial
      self.build_extension(ext)
    File "/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py", line 42, in build_extension
      build_ext.build_extension(self, ext)
    File "/Users//Users/path/to/folder/venv/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 178, in build_extension
      _build_ext.build_extension(self, ext)
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build_ext.py", line 529, in build_extension
      objects = self.compiler.compile(sources,
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/ccompiler.py", line 574, in compile
      self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/unixccompiler.py", line 117, in _compile
      self.spawn(compiler_so + cc_args + [src, '-o', obj] +
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/ccompiler.py", line 910, in spawn
      spawn(cmd, dry_run=self.dry_run)
    File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/spawn.py", line 66, in spawn
      if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
  AttributeError: 'int' object has no attribute 'split'
  ----------------------------------------
  ERROR: Failed building wheel for MarkupSafe
  Running setup.py clean for MarkupSafe
Failed to build MarkupSafe
Installing collected packages: MarkupSafe, Werkzeug, Jinja2, itsdangerous, Flask
    Running setup.py install for MarkupSafe ... error
    ERROR: Command errored out with exit status 1:
     command: /Users//Users/path/to/folder/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py'"'"'; __file__='"'"'/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-record-86v7atd3/install-record.txt --single-version-externally-managed --compile --install-headers /Users//Users/path/to/folder/venv/include/site/python3.9/MarkupSafe
         cwd: /private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/
    Complete output (81 lines):
    /usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'project_urls'
      warnings.warn(msg)
    /usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-11-x86_64-3.9
    creating build/lib.macosx-11-x86_64-3.9/markupsafe
    copying src/markupsafe/_constants.py -> build/lib.macosx-11-x86_64-3.9/markupsafe
    copying src/markupsafe/__init__.py -> build/lib.macosx-11-x86_64-3.9/markupsafe
    copying src/markupsafe/_native.py -> build/lib.macosx-11-x86_64-3.9/markupsafe
    copying src/markupsafe/_compat.py -> build/lib.macosx-11-x86_64-3.9/markupsafe
    running egg_info
    writing src/MarkupSafe.egg-info/PKG-INFO
    writing dependency_links to src/MarkupSafe.egg-info/dependency_links.txt
    writing top-level names to src/MarkupSafe.egg-info/top_level.txt
    reading manifest file 'src/MarkupSafe.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'docs/_build'
    warning: no previously-included files matching '*.py[co]' found anywhere in distribution
    writing manifest file 'src/MarkupSafe.egg-info/SOURCES.txt'
    copying src/markupsafe/_speedups.c -> build/lib.macosx-11-x86_64-3.9/markupsafe
    running build_ext
    building 'markupsafe._speedups' extension
    creating build/temp.macosx-11-x86_64-3.9
    creating build/temp.macosx-11-x86_64-3.9/src
    creating build/temp.macosx-11-x86_64-3.9/src/markupsafe
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/Users//Users/path/to/folder/venv/include -I/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/markupsafe/_speedups.c -o build/temp.macosx-11-x86_64-3.9/src/markupsafe/_speedups.o
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py", line 105, in <module>
        run_setup(True)
      File "/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py", line 53, in run_setup
        setup(
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Users/path/to/folder/venv/lib/python3.9/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/install.py", line 546, in run
        self.run_command('build')
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py", line 36, in run
        build_ext.run(self)
      File "/Users/path/to/folder/venv/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 66, in run
        _build_ext.run(self)
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build_ext.py", line 340, in run
        self.build_extensions()
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build_ext.py", line 449, in build_extensions
        self._build_extensions_serial()
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build_ext.py", line 474, in _build_extensions_serial
        self.build_extension(ext)
      File "/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py", line 42, in build_extension
        build_ext.build_extension(self, ext)
      File "/Users/path/to/folder/venv/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 178, in build_extension
        _build_ext.build_extension(self, ext)
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/build_ext.py", line 529, in build_extension
        objects = self.compiler.compile(sources,
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/ccompiler.py", line 574, in compile
        self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/unixccompiler.py", line 117, in _compile
        self.spawn(compiler_so + cc_args + [src, '-o', obj] +
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/ccompiler.py", line 910, in spawn
        spawn(cmd, dry_run=self.dry_run)
      File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/spawn.py", line 66, in spawn
        if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
    AttributeError: 'int' object has no attribute 'split'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/path/to/folder/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py'"'"'; __file__='"'"'/private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-install-sb0tfj2q/markupsafe_e3db55149f5e41369ae6e06e7eb56406/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/cj/q_3ynbn564962bgf9614pgpc0000gn/T/pip-record-86v7atd3/install-record.txt --single-version-externally-managed --compile --install-headers /Users/path/to/folder/venv/include/site/python3.9/MarkupSafe Check the logs for full command output.
(venv) 

(I censored the path in this code block, everything else is original)

With googling I found different solutions, like downgrading setuptools to 21.2.1 for example, installing python wheel. I did not find MarkupSafe Wheels.

But nothing helped, even trying to install flask by easy_install was unsuccessful.

Maybe someone encountered the same problem and can help me or has any idea?

"Downgrading" to Python 3.8 solved this problem as flask does not support Python 3.9. Thanks for helping @ sahasrara62 and @ A DUBEY!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM