安装基于 pyproject.toml 的项目需要 Typed-ast 辅助构建轮子

问题描述 投票:0回答:1

我尝试使用

pip install -r requirements.txt
在 Django 项目中安装需求,但它总是生成相同的错误。我无法找到解决方案,我尝试了互联网上建议的所有内容。

我使用的版本是:

Python-3.11.1 输入-ast==1.4.2

我降级了 python 和 typed-ast 版本,看看它是否有效......但它不起作用。

      h(457): error C2143: syntax error: missing '{' before '*'
      C:\Users\Aliza Paudel\AppData\Local\Temp\pip-install-13jms7r1\typed-ast_5878f64c514840fdb0c3d18010aba49b\ast27\Custom\../Include/Python-ast.h(457): error C2059: syntax error: ')'
      C:\Users\Aliza Paudel\AppData\Local\Temp\pip-install-13jms7r1\typed-ast_5878f64c514840fdb0c3d18010aba49b\ast27\Custom\../Include/Python-ast.h(459): error C2143: syntax error: missing ')' before '*'
      C:\Users\Aliza Paudel\AppData\Local\Temp\pip-install-13jms7r1\typed-ast_5878f64c514840fdb0c3d18010aba49b\ast27\Custom\../Include/Python-ast.h(459): fatal error C1003: error count exceeds 100; stopping compilation
      error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for typed-ast
  Failed to build typed-ast
  ERROR: Could not build wheels for typed-ast, which is required to install pyproject.toml- 
  based projects
  (venv) PS C:\ALL_FILES\Projected\kvwsmb>

我的requirements.txt看起来像这样。

pytz==2021.1  # https://github.com/stub42/pytz
python-slugify==4.0.1  # https://github.com/un33k/python-slugify
argon2-cffi==20.1.0  # https://github.com/hynek/argon2_cffi
redis==3.5.3  # https://github.com/andymccurdy/redis-py
hiredis==1.1.0  # https://github.com/redis/hiredis-py
typed-ast==1.4.2

tablib
# Django
# ------------------------------------------------------------------------------
django==3.1.7  # pyup: < 3.2  # https://www.djangoproject.com/
django-environ==0.4.5  # https://github.com/joke2k/django-environ
django-model-utils==4.1.1  # https://github.com/jazzband/django-model-utils
django-allauth==0.44.0  # https://github.com/pennersr/django-allauth
django-crispy-forms==1.11.1  # https://github.com/django-crispy-forms/django-crispy-forms
django-redis==4.12.1  # https://github.com/jazzband/django-redis
django-cors-headers 
django-rest-passwordreset
pillow
gunicorn
Collectfast
dj-database-url
django-autoslug
django-rest-knox
django-import-export
Werkzeug==1.0.1 # https://github.com/pallets/werkzeug
ipdb==0.13.5  # https://github.com/gotcha/ipdb
# https://github.com/psycopg/psycopg2

# Testing
# ------------------------------------------------------------------------------
mypy==0.812  # https://github.com/python/mypy
django-stubs==1.7.0  # https://github.com/typeddjango/django-stubs
pytest==6.2.2  # https://github.com/pytest-dev/pytest
pytest-sugar==0.9.4  # https://github.com/Frozenball/pytest-sugar

# Documentation
# ------------------------------------------------------------------------------
sphinx==3.5.1  # https://github.com/sphinx-doc/sphinx
sphinx-autobuild==2020.9.1 # https://github.com/GaretJax/sphinx-autobuild

# Code quality
# ------------------------------------------------------------------------------
flake8==3.8.4  # https://github.com/PyCQA/flake8
flake8-isort==4.0.0  # https://github.com/gforcada/flake8-isort
coverage==5.5  # https://github.com/nedbat/coveragepy
black==20.8b1  # https://github.com/ambv/black
pylint-django==2.4.2  # https://github.com/PyCQA/pylint-django
pre-commit==2.10.1  # https://github.com/pre-commit/pre-commit

# Django
# ------------------------------------------------------------------------------
factory-boy==3.2.0  # https://github.com/FactoryBoy/factory_boy

django-debug-toolbar==3.2  # https://github.com/jazzband/django-debug-toolbar
django-extensions==3.1.1  # https://github.com/django-extensions/django-extensions
django-coverage-plugin==1.8.0  # https://github.com/nedbat/django_coverage_plugin
pytest-django==4.1.0  # https://github.com/pytest-dev/pytest-django
whitenoise
djangorestframework
django-filter
django-tables2
drf-yasg
django-filter
python django pip python-wheel
1个回答
0
投票
**The error you're encountering with typed-ast during installation often stems from issues with the C compiler or the environment settings.Try**

Update typed-ast:

    text
    
    typed-ast
    Install Build Tools:
    Ensure you have the necessary build tools installed. For Windows, you might need to install the Visual Studio build tools.
    
    Download and install Microsoft C++ Build Tools.
    During the installation, ensure you select "Desktop development with C++".
    Set Up Environment Variables:
    Sometimes, the issue can be resolved by setting the correct environment variables for the compiler. Open a terminal and run:
    
    sh
   
    setx INCLUDE "C:\Program Files (x86)\Windows Kits\10\Include\<your_version>\ucrt"
    setx INCLUDE "C:\Program Files (x86)\Windows Kits\10\Include\<your_version>\shared"
    setx LIB "C:\Program Files (x86)\Windows Kits\10\Lib\<your_version>\ucrt\x64"
    setx LIB "C:\Program Files (x86)\Windows Kits\10\Lib\<your_version>\um\x64"
    Use Pre-compiled Binaries:
    If building from source continues to fail, you can try installing pre-compiled binaries. Use pip to install a wheel file directly from a repository that provides pre-compiled binaries. For example:
    
    sh
    pip install typed-ast --only-binary :all:
    Check for Conflicts:
    Ensure there are no conflicting versions or packages. Create a clean virtual environment and try installing only the necessary packages first:
    
    sh
    Copy code
    python -m venv myenv
    myenv\Scripts\activate
    pip install --upgrade pip
    pip install -r requirements.txt
    Specific Fix for typed-ast Compilation Error:
    If the issue persists, try installing typed-ast directly before the other packages:
    
    sh
    pip install typed-ast==1.4.2
    pip install -r requirements.txt
© www.soinside.com 2019 - 2024. All rights reserved.