无法在 PyCharm 中安装 Flask [英] Unable to install Flask in PyCharm

查看:92
本文介绍了无法在 PyCharm 中安装 Flask的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PyCharm 中安装 Flask 时遇到问题.当我尝试运行 pip install flask 时出现以下错误.

ERROR: 命令出错,退出状态为 1:命令:'c:Users
ohitAppDataLocalProgramsPythonPython38-32python.exe' -u -c 'import sys, setuptools, tokenize;sys.argv[0] = '"'"'C:\Users\rohit\AppData\Local\Temp\pip-install-7tccrr01\MarkupSafe\setup.py'"'"';__file__='"'"'C:\Users\rohit\AppData\Local\Temp\pip-install-7tccrr01\MarkupSafe\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:Users
ohitAppDataLocalTemppip-record-q_wdekk3install-record.txt' --single-version-externally-managed --compilecwd: C:Users
ohitAppDataLocalTemppip-install-7tccrr01MarkupSafe完整输出(23 行):运行安装运行构建运行 build_py创建构建创建 buildlib.win32-3.8创建 buildlib.win32-3.8markupsafe复制 srcmarkupsafe\_compat.py ->构建lib.win32-3.8markupsafe复制 srcmarkupsafe\_constants.py ->构建lib.win32-3.8markupsafe复制 srcmarkupsafe\_native.py ->构建lib.win32-3.8markupsafe复制 srcmarkupsafe\__init__.py ->构建lib.win32-3.8markupsafe运行 egg_info写 srcMarkupSafe.egg-infoPKG-INFO将 dependency_links 写入 srcMarkupSafe.egg-infodependency_links.txt将顶级名称写入 srcMarkupSafe.egg-info	op_level.txt读取清单文件 'srcMarkupSafe.egg-infoSOURCES.txt'阅读清单模板'MANIFEST.in'未找到与docs\_build"匹配的先前包含的目录警告:在分发的任何地方都找不到与*.py [co]"匹配的先前包含的文件编写清单文件 'srcMarkupSafe.egg-infoSOURCES.txt'复制 srcmarkupsafe\_speedups.c ->构建lib.win32-3.8markupsafe运行 build_ext构建markupsafe._speedups"扩展错误:[WinError 3] 系统找不到指定的路径:'C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\lib'----------------------------------------错误:命令出错,退出状态为 1:'c:Users
ohitAppDataLocalProgramsPythonPython38-32python.exe' -u -c 'import sys, setuptools, tokenize;sys.argv[0] = '"'"'C:\Users\rohit\AppData\Local\Temp\pip-install-7tccrr01\MarkupSafe\setup.py'"'"';__file__='"'"'C:\Users\rohit\AppData\Local\Temp\pip-install-7tccrr01\MarkupSafe\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:Users
ohitAppDataLocalTemppip-record-q_wdekk3install-record.txt' --single-version-externally-managed --compile 检查日志以获取完整的命令输出.

解决方案

默认情况下,PyCharm 使用 pip 来管理项目包.要管理项目解释器的 Python 包,请选择项目中的项目解释器页面Settings/Preferences 或选择 Python 解释器小部件中的 解释器设置.

选择文件 -> 设置 -> 项目: project_name -> 项目解释器.单击屏幕截图中鼠标光标标记的+按钮,在所选项目中安装Python包.

搜索烧瓶.选择它并单击可用软件包窗口左下角的 Install Package 按钮进行安装.PyCharm 会自动为您选择软件包版本,或者您可以选中 Specify version 左侧的复选框,然后从 Specify version 下拉菜单中选择软件包版本.

每当您

然后勾选Inherit global-site packages复选框并点击Create Project窗口右下角的 Create 按钮.

I have trouble installing Flask in PyCharm. I got the following errors when I tried to run pip install flask.

ERROR: Command errored out with exit status 1:
     command: 'c:Users
ohitAppDataLocalProgramsPythonPython38-32python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\rohit\AppData\Local\Temp\pip-install-7tccrr01\MarkupSafe\setup.py'"'"'; __file__='"'"'C:\Users\rohit\AppData\Local\Temp\pip-install-7tccrr01\MarkupSafe\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:Users
ohitAppDataLocalTemppip-record-q_wdekk3install-record.txt' --single-version-externally-managed --compile
         cwd: C:Users
ohitAppDataLocalTemppip-install-7tccrr01MarkupSafe
    Complete output (23 lines):
    running install
    running build
    running build_py
    creating build
    creating buildlib.win32-3.8
    creating buildlib.win32-3.8markupsafe
    copying srcmarkupsafe\_compat.py -> buildlib.win32-3.8markupsafe
    copying srcmarkupsafe\_constants.py -> buildlib.win32-3.8markupsafe
    copying srcmarkupsafe\_native.py -> buildlib.win32-3.8markupsafe
    copying srcmarkupsafe\__init__.py -> buildlib.win32-3.8markupsafe
    running egg_info
    writing srcMarkupSafe.egg-infoPKG-INFO
    writing dependency_links to srcMarkupSafe.egg-infodependency_links.txt
    writing top-level names to srcMarkupSafe.egg-info	op_level.txt
    reading manifest file 'srcMarkupSafe.egg-infoSOURCES.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 'srcMarkupSafe.egg-infoSOURCES.txt'
    copying srcmarkupsafe\_speedups.c -> buildlib.win32-3.8markupsafe
    running build_ext
    building 'markupsafe._speedups' extension
    error: [WinError 3] The system cannot find the path specified: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\lib'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:Users
ohitAppDataLocalProgramsPythonPython38-32python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\rohit\AppData\Local\Temp\pip-install-7tccrr01\MarkupSafe\setup.py'"'"'; __file__='"'"'C:\Users\rohit\AppData\Local\Temp\pip-install-7tccrr01\MarkupSafe\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:Users
ohitAppDataLocalTemppip-record-q_wdekk3install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

解决方案

By default, PyCharm uses pip to manage project packages. To manage Python packages for the project interpreter, select the Project Interpreter page in the project Settings/Preferences or select Interpreter Settings in the Python Interpreter widget.

Select File -> Settings -> Project: project_name -> Project Interpreter. Click the + button which is marked by the mouse cursor in the screenshot to install Python packages in the selected project.

Search for Flask. Select it and click the Install Package button in the lower left corner of the Available Packages window to install it. PyCharm will automatically choose the package version for you or you can check the checkbox to the left of Specify version and select the package version from the Specify version dropdown menu.

Whenever you install a Python package specifically for a project, PyCharm adds the packages that were installed to the project's venv directory where PyCharm will find them automatically.

PyCharm does not automatically find your globally installed Python packages unless the project has been configured to find them. To do this select the Inherit global-site packages option when you create a new project.

Select File -> New Project to create a new project. Click the triangle marked by the mouse cursor in the below screenshot to show the new project's options.

Then check the Inherit global-site packages checkbox and click the Create button in the lower right corner of the Create Project window.

这篇关于无法在 PyCharm 中安装 Flask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆