【问题标题】:Issues with pipenv install on M1 Mac for python dependencies在 M1 Mac 上安装 pipenv 以获取 python 依赖项的问题
【发布时间】:2022-10-20 02:18:59
【问题描述】:

我正在尝试建立一个最初在基于英特尔的 mac 上创建的本地存储库。该存储库使用 pyenv 和 pipenv 来管理 python 依赖项。每当我尝试运行pipenv install 时,都会收到以下错误:

ERROR:pip.subprocessor:[present-rich] pip subprocess to install build dependencies exited with 1
[ResolutionFailure]:   File "/Users/xur19/.pyenv/versions/3.8.10/lib/python3.8/site-packages/pipenv/resolver.py", line 782, in _main
[ResolutionFailure]:       resolve_packages(
[ResolutionFailure]:   File "/Users/xur19/.pyenv/versions/3.8.10/lib/python3.8/site-packages/pipenv/resolver.py", line 730, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "/Users/xur19/.pyenv/versions/3.8.10/lib/python3.8/site-packages/pipenv/resolver.py", line 709, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "/Users/xur19/.pyenv/versions/3.8.10/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 1105, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "/Users/xur19/.pyenv/versions/3.8.10/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 894, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/Users/xur19/.pyenv/versions/3.8.10/lib/python3.8/site-packages/pipenv/utils/resolver.py", line 689, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: pip subprocess to install build dependencies exited with 1

存储库有一个现有的 Pipfile 和 Pipfile.lock

我的设置步骤是:

brew install pyenv
pyenv install 3.8.7
pyenv global 3.8.7
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init)"\nfi' >> ~/.zshrc
brew install python
pip install pipenv
pipenv shell
pipenv install

我的 Mac 是 M1 mac,我尝试了以下方法:

  • 尝试使 repo 与 ARM 架构一起工作。我尝试使用 python 3.8.10 而不是 3.8.7,因为它是支持 M1 芯片的最新版本,并且我尝试删除一些不支持 M1 的未使用依赖项(cx-oracle )。我也尝试过运行pipenv lock --prepipenv install --skip-lock,但这两者都会导致相同的错误。我也尝试过删除我的 Pipfile.lock 并且只使用 Pipfile,但这也失败了。
  • 尝试使 repo 与 Rosetta 2 一起工作。我尝试使用 Rosetta 安装自制软件(到 /usr/local/bin/brew),并且我使用了带有 brew 的 arch -x86_64 前缀(启用了单独的 Rosetta终端,改变了我的路径等)。当我尝试这样做时,我会遇到类似的错误。我已经查看了几篇描述如何使用 Rosetta 安装 python/pipenv/pyenv 的 stackoverflow 和 medium 文章,但我无法克服这个错误。

我不确定还有什么可以尝试的——想知道是否有人对如何解决这个问题提出了建议。对于上下文,这是我的 Pipfile。

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
autopep8 = "*"
flake8 = "*"
black = "==20.8b1"

[packages]
celery = "==4.4.7"
channels = "==3.0.3"
channels-redis = "==3.2.0"
#cx_Oracle = "==8.2.1" # Django DATABASE
Django = "==2.2.24"
django-allauth = "==0.44.0"
django-celery-beat = "==2.2.0"
django-cors-headers = "==3.7.0"
django-enumfield = "==1.5"
django-environ = "==0.4.5"
django-extensions = "==3.1.2"
django-filter = "==2.1.0"
django-graphql-jwt = "==0.3.1"
django-graphql-persist = "==0.1.1"
django-jet = "==1.0.8"
django-redis = "==4.12.1"
django-reversion = "==3.0.9"
django-reversion-compare = "==0.14.0"
django-measurement = "==3.2.3"
django-jsoneditor = "==0.1.6"
django-storages = {extras = ["google"],version = "==1.11.1"}
flower = "==0.9.7"
future = "==0.18.2"
google-auth = "==1.29.0"
google-auth-oauthlib = "==0.4.4"
google-cloud-storage = "==1.37.1"
google-cloud-pubsub = "==2.4.0"
graphene = "==2.1.7"
graphql-core = "==2.2"
graphene-django = "==2.7"
graphene-file-upload = "==1.3.0"
graphql-relay = "==2"
graphql-server-core = "==1.1.1"
gunicorn = "==19.9.0"
ijson = "==3.1.4"
ldap3 = "==2.9"
matplotlib = "==3.4.1"
munch = "==2.5.0"
numpy = "==1.20.2"
openpyxl = "==3.0.7"
pandas = "==1.2.4"
pillow = "==8.2.0"
psycopg2-binary = "==2.8.6"
pyhumps = "==1.6.1"
pyjwt = "==1.7.1"
pymongo = "==3.11.3"
pyteomics = "==4.4.2"
python-pptx = "==0.6.18"
pytz = "==2018.9"
redis = "==3.2.0" # Doesn't get installed by django-redis
requests = "==2.21.0"
tqdm = "==4.60.0"
xlrd = "==2.0.1"
jinja2 = "==3.0.2"
premailer = "==3.10.0"
docxtpl = "==0.14.2"
inflection = "==0.4.0"
sympy = "==1.9"

[requires]
python_version = "3.7"

【问题讨论】:

    标签: python apple-m1 pipenv pyenv rosetta


    【解决方案1】:

    我不是 100% 确定,因为我正在处理 3.7.10,但我的问题看起来非常相似。基于this issue on pipenv,我被引导到this article,这让我找到了解决方案。

    该文章总结的解决方案如下。

    我不确定您是否需要从 brew 安装 libffi 并进行这些导出,但我陷入困境,所以它可能会有所帮助。

    brew install libffi
    export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"
    export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"
    

    这部分你绝对需要做。

    CONFIGURE_OPTS='--with-system-ffi' pyenv install 3.7.10
    pyenv local 3.7.10
    

    然后编辑导致MemoryError 的文件。对于 3.7.10 ~/.pyenv/versions/3.7.10/lib/python3.7/ctypes/__init__.py。注释或删除此函数的最后一行。

    def _reset_cache():
        _pointer_type_cache.clear()
        _c_functype_cache.clear()
        if _os.name == "nt":
            _win_functype_cache.clear()
        # _SimpleCData.c_wchar_p_from_param
        POINTER(c_wchar).from_param = c_wchar_p.from_param
        # _SimpleCData.c_char_p_from_param
        POINTER(c_char).from_param = c_char_p.from_param
        _pointer_type_cache[None] = c_void_p
        # XXX for whatever reasons, creating the first instance of a callback
        # function is needed for the unittests on Win64 to succeed.  This MAY
        # be a compiler bug, since the problem occurs only when _ctypes is
        # compiled with the MS SDK compiler.  Or an uninitialized variable?
        CFUNCTYPE(c_int)(lambda: None) # comment or remove me
    

    然后它对我有用。 pipenv 安装了很多东西没有问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-30
      • 2019-04-29
      • 2023-02-18
      • 2021-07-29
      • 1970-01-01
      • 2019-01-02
      • 2023-03-12
      • 2021-10-24
      相关资源
      最近更新 更多