简体   繁体   English

OSError:运行subprocess.Popen时出现[Errno 8] Exec格式错误

[英]OSError: [Errno 8] Exec format error when running subprocess.Popen

Im trying to run some open source code I downloaded from github: https://github.com/augustoqm/MCLRE 我试图运行一些我从github下载的开源代码: https//github.com/augustoqm/MCLRE

The code is running from my mac shell. 代码从我的mac shell运行。 When it reaches the subprocess.Popen() function it raise an "OSError: [Errno 8] Exec format error". 当它到达subprocess.Popen()函数时,它会引发“OSError:[Errno 8] Exec格式错误”。

The code: 编码:

Start the new process 开始新流程

mrbpr_cmd_args = '%s -m %s -d %s -u %s -n %s -o %s -k %d -s %d -h %d -l %f -f %d -i %d -a %s -e "%s" -r "%s" -M %s' \\ % (mrbpr_bin_path, meta_file, train_files, test_users_file, test_candidates_file, output_dir, rank_size, \\ save_model, algorithm, learn_rate, num_fact, num_iter, relation_weights, regularization_per_entity, \\ regularization_per_entity, model_name) mrbpr_cmd_args ='%s -m%s -d%s -u%s -n%s -o%s -k%d -s%d -h%d -l%f -f%d -i%d - a%s -e“%s”-r“%s”-M%s'\\%(mrbpr_bin_path,meta_file,train_files,test_users_file,test_candidates_file,output_dir,rank_size,\\ save_model,algorithm,learn_rate,num_fact,num_iter,relation_weights, regularization_per_entity,\\ regularization_per_entity,model_name)

proc = subprocess.Popen(shlex.split(mrbpr_cmd_args), shell=True) proc = subprocess.Popen(shlex.split(mrbpr_cmd_args),shell = True)

When I print "mrbpr_cmd_args" variable the results are: 当我打印“mrbpr_cmd_args”变量时,结果是:

/Users/nastia/Desktop/MCLRE-master/src/recommender_execution/mrbpr/mrbpr.bin -m /Users/nastia/Desktop/MCLRE-master/data/experiments/recsys-15/bpr-net_meetup.meta -d /Users/nastia/Desktop/MCLRE-master/data/partitioned_data/san_jose/partition_12/mrbpr/user-event-rsvp_train.tsv,/Users/nastia/Desktop/MCLRE-master/data/partitioned_data/san_jose/partition_12/mrbpr/user-user-same-group_train.tsv,/Users/nastia/Desktop/MCLRE-master/data/partitioned_data/san_jose/partition_12/mrbpr/user-user-same-event_train.tsv -u /Users/nastia/Desktop/MCLRE-master/data/partitioned_data/san_jose/partition_12/mrbpr/users_test.tsv -n /Users/nastia/Desktop/MCLRE-master/data/partitioned_data/san_jose/partition_12/mrbpr/event-candidates_test.tsv -o /Users/nastia/Desktop/MCLRE-master/data/experiments/recsys-15/san_jose/recommendations/partition_12/mrbpr -k 100 -s 0 -h 0 -l 0.100000 -f 200 -i 600 -a 0.25,0.15,0.6 -e "" -r "" -M BPR-NET_200-0.1-600-0.25:0.15:0.6 /Users/nastia/Desktop/MCLRE-master/src/recommender_execution/mrbpr/mrbpr.bin -m /Users/nastia/Desktop/MCLRE-master/data/experiments/recsys-15/bpr-net_meetup.meta -d / Users /nastia/Desktop/MCLRE-master/data/partitioned_data/san_jose/partition_12/mrbpr/user-event-rsvp_train.tsv,/Users/nastia/Desktop/MCLRE-master/data/partitioned_data/san_jose/partition_12/mrbpr/user- user-same-group_train.tsv,/ Users / nastia / Desktop / MCLRE-master / data / partitioned_data / san_jose / partition_12 / mrbpr / user-user-same-event_train.tsv -u / Users / nastia / Desktop / MCLRE-master /data/partitioned_data/san_jose/partition_12/mrbpr/users_test.tsv -n /Users/nastia/Desktop/MCLRE-master/data/partitioned_data/san_jose/partition_12/mrbpr/event-candidates_test.tsv -o / Users / nastia / Desktop / MCLRE-master / data / experiments / recsys-15 / san_jose / recommendations / partition_12 / mrbpr -k 100 -s 0 -h 0 -l 0.100000 -f 200 -i 600 -a 0.25,0.15,0.6 -e“” - r“”-M BPR-NET_200-0.1-600-0.25:0.15:0.6

Can anyone please tell me what is wrong with this args? 谁能告诉我这个args有什么问题?

From the README on the GitHub repo you linked: 从您链接的GitHub回购的README:

Requirements 要求

  • Linux: all experiments were executed in Linux-based machines, Ubuntu distributions, more specifically Linux:所有实验都是在基于Linux的机器,Ubuntu发行版中执行的,更具体地说

And, if you look at that path inside the repo , mrbpr.bin is a Linux executable binary. 而且,如果你看看repo中的那条路径mrbpr.bin是一个Linux可执行二进制文件。 You can't run that on a Mac. 你无法在Mac上运行它。

If they provide the source to build that executable yourself, or a link to where to find it, you could probably build a Mac version. 如果他们提供了自己构建可执行文件的源代码,或者找到它的链接,那么您可以构建一个Mac版本。 But, failing that, there's nothing you can do to fix it. 但是,如果不这样做,你无法解决它。


The best option would probably be to run a Linux container, virtual machine, or user-mode installation (either on your Mac, or on some free cloud host), install Python and all of the other requirements into that, and run the code that way. 最好的选择可能是运行Linux容器,虚拟机或用户模式安装(在Mac上或在一些免费的云主机上),安装Python和所有其他要求,然后运行代码方式。


If you're wondering why you got that particular error: 如果您想知道为什么会遇到这个特定错误:

OSError: [Errno 8] Exec format error

There are a variety of different executable formats out there: a.out, ELF, mach-O, COFF, etc. Most linux executables are in ELF format. 有各种不同的可执行格式:a.out,ELF,mach-O,COFF等。大多数Linux可执行文件都是ELF格式。 macOS's loader only knows mach-O and a.out. macOS的加载器只知道mach-O和a.out。 So, your OS can't even figure out what the file is, only that it's not a file it knows how to handle. 因此,您的操作系统甚至无法弄清楚文件是什么,只是它不是一个知道如何处理的文件。 But, even if you got past that, linux and Darwin syscalls are different, glibc and BSD libc are different, etc., so it would just quickly segfault anyway. 但是,即使你已经过去了,linux和Darwin系统调用是不同的,glibc和BSD libc也是不同的,所以无论如何它都会很快发生段错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM