首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >关于python依赖项在M1 Mac上安装pipenv的问题

关于python依赖项在M1 Mac上安装pipenv的问题
EN

Stack Overflow用户
提问于 2022-10-05 22:59:16
回答 1查看 726关注 0票数 1

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

代码语言:javascript
复制
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

我的安装步骤如下:

代码语言:javascript
复制
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,我尝试了以下几种:

  • 试着让回购与ARM架构一起工作。我尝试使用python3.8.10而不是3.8.7,因为这是支持M1芯片的最新版本,我还尝试删除一些不支持M1 (Cx)的依赖项。我也尝试过运行pipenv lock --prepipenv install --skip-lock,但这两者都会导致相同的错误。我也尝试过删除我的Pipfile.lock,并且只使用Pipfile,但是也失败了。
  • 我尝试用Rosetta 2安装自制软件(to /usr/local/bin/ brew ),我在brew中使用了arch -x86_64前缀(带有单独的Rosetta启用终端,更改了路径等等)。当我尝试的时候,我也会遇到类似的错误。我回顾了几篇描述如何使用Rosetta安装python/pipenv/pyenv的堆栈溢出和媒体文章,但我无法克服这个错误。

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

代码语言:javascript
复制
[[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"
EN

回答 1

Stack Overflow用户

发布于 2022-10-19 18:18:59

我不是百分之百肯定,因为我处理的是3.7.10,但我的问题看起来很相似。基于关于pipenv的这个问题,我被引导到这篇文章,这使我找到了一个解决方案。

该条概述的解决方案如下。

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

代码语言:javascript
复制
brew install libffi
export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"

这部分你一定要做。

代码语言:javascript
复制
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。注释或删除此函数的最后一行。

代码语言:javascript
复制
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安装了很多东西,没有问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73967109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档