macos 在 Mac 上安装 R - 警告消息:设置 LC_CTYPE 失败,使用“C”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9689104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing R on Mac - Warning messages: Setting LC_CTYPE failed, using "C"
提问by nassimhddd
I would like install R on my laptop Mac OS X version 10.7.3
我想在我的笔记本电脑 Mac OS X 版本 10.7.3 上安装 R
I downloaded the last version and I double click on it and it was installed, when i start up I get the following error, I searched in internet but I could not solve the problem, any help would be appreciated
我下载了最后一个版本并双击它并安装了它,当我启动时出现以下错误,我在互联网上搜索但我无法解决问题,任何帮助将不胜感激
the errors are
错误是
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_PAPER failed, using "C"
[R.app GUI 1.50 (6126) x86_64-apple-darwin9.8.0]WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will work. Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system preferences accordingly. [History restored from /Users/nemo/.Rapp.history]
启动期间 - 警告消息:
1:设置 LC_CTYPE 失败,使用“C”
2:设置 LC_COLLATE 失败,使用“C”
3:设置 LC_TIME 失败,使用“C”
4:设置 LC_MESSAGES 失败,使用“C”
5:设置 LC_PAPER失败,使用“C”
[R.app GUI 1.50 (6126) x86_64-apple-darwin9.8.0]警告:您使用的是非 UTF8 语言环境,因此只能使用 ASCII 字符。请阅读 R for Mac OS X FAQ(请参阅帮助)第 9 部分并相应地调整您的系统首选项。[从 /Users/nemo/.Rapp.history 恢复的历史]
回答by nassimhddd
- Open Terminal
- Write or paste in:
defaults write org.R-project.R force.LANG en_US.UTF-8
- Close Terminal (including any RStudio window)
- Start R
- 打开终端
- 写入或粘贴:
defaults write org.R-project.R force.LANG en_US.UTF-8
- 关闭终端(包括任何 RStudio 窗口)
- 启动 R
回答by Jarno Keskikangas
Setting locales in terminal resolved the issue for me. Open the terminal and
在终端中设置语言环境为我解决了这个问题。打开终端并
Check if locale settings are missing
> locale LANG= LC_COLLATE="C" LC_CTYPE="UTF-8" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL=
Edit
~/.profile
or~/.bashrc
export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8
Run
. ~/.profile
or. ~/.bashrc
to read from the file.Open a new terminal window and check that the locales are properly set
> locale LANG="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_CTYPE="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_ALL="en_US.UTF-8"
检查区域设置是否丢失
> locale LANG= LC_COLLATE="C" LC_CTYPE="UTF-8" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL=
编辑
~/.profile
或~/.bashrc
export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8
运行
. ~/.profile
或. ~/.bashrc
从文件中读取。打开一个新的终端窗口并检查区域设置是否正确设置
> locale LANG="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_CTYPE="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_ALL="en_US.UTF-8"
回答by user3512330
Just open the R(software) and copy and paste
只需打开R(软件)并复制并粘贴
system("defaults write org.R-project.R force.LANG en_US.UTF-8")
Hope this will work fine or use the other method
希望这会正常工作或使用其他方法
open(on mac): Utilities/Terminal copy and paste
defaults write org.R-project.R force.LANG en_US.UTF-8
and close both terminal and R
and reopen R
.
并关闭两个终端R
并重新打开R
。
回答by Bhoom Suktitipat
I found slightly different problem running R on through mac terminal, but connecting remotely to an Ubuntu server, which prevented me from successfully installing a library.
我发现通过 mac 终端运行 R 的问题略有不同,但远程连接到 Ubuntu 服务器,这使我无法成功安装库。
The solution I have was finding out what "LANG" variable is used in Ubuntu terminal
我的解决方案是找出 Ubuntu 终端中使用的“LANG”变量
Ubuntu > echo $LANG
en_US.TUF-8
I got "en_US.TUF-8" reply from Ubuntu.
我收到了来自 Ubuntu 的“en_US.TUF-8”回复。
In R session, however, I got "UTF-8" as the default value and it complained that LC_TYPEC Setting LC_CTYPE failed, using "C"
然而,在 R 会话中,我将“UTF-8”作为默认值,它抱怨说 LC_TYPEC Setting LC_CTYPE failed, using "C"
R> Sys.getenv("LANG")
"UTF-8"
So, I tried to change this variable in R. It worked.
所以,我试图在 R 中改变这个变量。它起作用了。
R> Sys.setenv(LANG="en_US.UTF-8")
回答by Ennio De Leon
Tks Ramon Gil Moreno.
Pasting in Terminal and then restarting R Studio did the trick:
write org.rstudio.RStudio force.LANG en_US.UTF-8
Tks 拉蒙吉尔莫雷诺。在终端中粘贴然后重新启动 R Studio 就可以了:
编写 org.rstudio.RStudio force.LANG en_US.UTF-8
Environment: MACOS High Sierra 10.13.1 // RStudioversion 3.4.2 (2017-09-28) -- "Short Summer"
环境: MACOS High Sierra 10.13.1 // RStudioversion 3.4.2 (2017-09-28) -- 《Short Summer》
Ennio De Leon
恩尼奥·德莱昂
回答by adietster
On my Mac r is installed in /usr/local/bin/r
, add line below in .bash_profile
solved the same problem:
在我的 Mac 上安装了 r /usr/local/bin/r
,在下面添加一行以.bash_profile
解决同样的问题:
alias r="LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 r"