无法在R中导入 pandas [英] Not able to import pandas in R

查看:96
本文介绍了无法在R中导入 pandas 的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从R/shiny调用一个python脚本为:

I am calling a python script from R/shiny as:

system("python /Users/Downloads/Untitled3.py EMEA regulatory '10% productivity saves SOW'")

它不能导入熊猫.

但是当我从终端直接调用脚本时:

But when I straight call the script from the terminal as:

python /Users/Downloads/Untitled3.py EMEA regulatory '10% productivity saves SOW'

它能够导入熊猫.我猜python中有一些版本问题.我安装了蟒蛇.谁能帮助我纠正问题.

It is able to import pandas. I guess some version issue in python.I have anaconda installed. Can anyone of you please help me in rectifying the issue.

尽管不是必需的,但脚本的起始位置为:

Although not required as, script starts as:

import pandas as pd 
import numpy as np
import sys

from difflib import SequenceMatcher
##### More code#########

推荐答案

问题

您拥有默认的系统python,然后还有anaconda发行版.

You have the default system python and then the anaconda distribution as well.

仅运行从R运行的命令将调用默认系统python,该系统没有必需的软件包.

Merely running the command that you are running from R calls the default system python that doesn't have the required packages.

修复

假设您在/Users/<username>/anaconda/bin/python(这是默认的Mac安装文件夹)中安装了anaconda,

Assuming you have anaconda installed at /Users/<username>/anaconda/bin/python (that's the default mac installation folder),

您应运行的R命令是​​-

the R command that you should run is -

system("/Users/<username>/anaconda/bin/python /Users/Downloads/Untitled3.py EMEA regulatory '10% productivity saves SOW'")

这可确保您明确使用anaconda的python二进制文件,这些文件将在pandas和安装在其中的其他相关库中使用.

This ensures that you are explicitly using anaconda's python binaries which will pick up on the pandas and other relevant libraries installed there.

希望有帮助!

这篇关于无法在R中导入 pandas 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆