升级CocoaPods报错解决(ffi**** )

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20211117-13754-1pf53tk.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
	--with-ffi_c-dir
	--without-ffi_c-dir
	--with-ffi_c-include
	--without-ffi_c-include=${ffi_c-dir}/include
	--with-ffi_c-lib
	--without-ffi_c-lib=${ffi_c-dir}/lib
	--enable-system-libffi
	--disable-system-libffi
	--with-libffi-config
	--without-libffi-config
	--with-pkg-config
	--without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header'
	from extconf.rb:10:in `system_libffi_usable?'
	from extconf.rb:42:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-20/2.6.0/ffi-1.15.4/gem_make.out

遇到以上这个报错, 注意看倒数第4行那个log文件,打开 mkmf.log 文件。

里面找到 universal-darwin20 文件夹的路径,你的有可能是 universal-darwin21 

进入到这个文件夹里,复制 universal-darwin20 一份改成 universal-darwin19 就行了。 

当执行 `hg.edges(etype[0])` 出现 `dgl._ffi.base.DGLError: Edge type name must be specified if there are more than one edge types` 错误,这通常意味着异构图 `hg` 中有多种边类型,而在调用 `hg.edges()` 时需要明确指定边的类型。如果边类型名字唯一,则可仅使用边类型的名字;否则必须使用关系三元组(即规范的边类型)来指定边的类型 [^3]。 下面是解决该问题的具体步骤和示例代码: #### 确认边类型是否唯一 首先,查看异构图的所有边类型和规范边类型: ```python import dgl import torch # 构建一个简单的异构图 data_dict = { ('user', 'follows', 'user'): (torch.tensor([0, 1]), torch.tensor([1, 2])), ('user', 'plays', 'game'): (torch.tensor([0, 1]), torch.tensor([0, 1])) } hg = dgl.heterograph(data_dict) print("Edge types:", hg.etypes) print("Canonical edge types:", hg.canonical_etypes) ``` #### 根据边类型的唯一性选择合适的调用方式 - **边类型唯一**:如果边类型的名字唯一,则可直接使用边类型的名字: ```python if len(set(hg.etypes)) == len(hg.etypes): etype = 'follows' src, dst = hg.edges(etype) print(f"Edge type: {etype}, Source nodes: {src}, Destination nodes: {dst}") ``` - **边类型不唯一**:如果边类型的名字不唯一,则必须使用关系三元组(规范边类型): ```python # 假设存在不唯一的边类型 data_dict_non_unique = { ('user', 'interacts', 'user'): (torch.tensor([0, 1]), torch.tensor([1, 2])), ('user', 'interacts', 'game'): (torch.tensor([0, 1]), torch.tensor([0, 1])) } hg_non_unique = dgl.heterograph(data_dict_non_unique) canonical_etype = ('user', 'interacts', 'user') src, dst = hg_non_unique.edges(canonical_etype) print(f"Edge type: {canonical_etype}, Source nodes: {src}, Destination nodes: {dst}") ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值