在M1 Mac上安装pipenv以获得python依赖关系的问题



我正在尝试建立一个最初在基于英特尔的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; thenn  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,但也失败了
  • 试着让回购与罗塞塔2一起工作。我尝试过用Rosetta安装自制软件(到/usr/local/bin/brew(,并在brew中使用了arch-x86_64前缀(使用单独的启用了Rosetta的终端,更改了路径等(。当我尝试的时候,我会得到类似的错误。我已经阅读了几篇stackoverflow和medium文章,这些文章描述了如何使用Rosetta安装python/pipenv/pyenv,但我无法克服这个错误

我不知道还能尝试什么——我想知道是否有人对如何解决这个问题有建议。就上下文而言,这是我的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"

我不能100%确定,因为我处理的是3.7.10,但我的问题看起来可疑地相似。基于pipenv上的这个问题,我被引导到这篇文章,这篇文章让我找到了一个解决方案。

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

我不确定你是否需要从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安装了很多东西,没有出现问题。

相关内容

  • 没有找到相关文章

最新更新