导入Python lib'请求'在matlab中不起作用

时间:2017-02-06 13:59:15

标签: python matlab python-2.7

我在Mac OS x Sierra中使用matlab 2016b和Python 2.7。

当我导入RTLD_NOW = 2; RTLD_DEEPBIND = 8; flag = bitor(RTLD_NOW, RTLD_DEEPBIND); py.sys.setdlopenflags(int32(flag)); py.importlib.import_module('requests'); 时,我得到了一个没有模块的' python错误。同样适用于网络套接字'太。但是当我尝试在具有相同Python版本的终端中执行相同操作时,我获得了输出。

我已尝试过以下解决方案,但它无效。

res <- t(sapply(strsplit(test, " "), function(x) {
        i1 <- grep("[/]", x)
        x1 <- x[i1]
        d1 <- do.call(rbind.data.frame, strsplit(x1, "[/]"))[2:1]
        colnames(d1) <- c("key", "val")
        d1$key <- factor(d1$key, levels = c("POS", "NEG", "AD", "FE"))
        t1 <- t(table(d1))
        colSums(t1)}))
library(stringr)
res[,4] <- str_extract(test, "\\w+(?=/FE)")

1 个答案:

答案 0 :(得分:0)

您可以尝试使用

找到丢失的python模块
import the_missing_module
import os
path = os.path.dirname(the_missing_module.__file__)
print path

然后检查path是否在MATLAB搜索路径子集中。