Error “.onLoad failed in loadNamespace() for 'tcltk'”

情到浓时终转凉″ 提交于 2019-11-26 17:59:13
Thomas

tcltk is not a typical package. It's probably already installed on your system and it cannot be installed using the usual install.packages procedure because it is not on CRAN (just like the base packages that come with R, like stats, etc.). Also, tcltk2 is not the same as tcltk; that is a package that expands upon (and depends on) the functionality of tcltk.

So, start with this:

> capabilities("tcltk")
tcltk 
 TRUE

If that comes back FALSE it means that your R was not built with tcltk support. You don't say what OS you're using, so it's a little bit difficult to help you.

That said, if you're on Linux, you need to rebuild R with tcltk support. This should be relatively straightforward. Basically, make sure Tcl and tk are available on your system in a standard location (something like sudo apt-get install tcl8.5-dev tk8.5-dev) and then rebuild R per usual procedures.

If you're on Mac OS, you're encountering the same error that John Fox describes here in relation to Rcmdr. In short, it's probably one of two things:

  1. A file permission issue related to the directory where you have Tcl installed. To quote Fox: "You can verify the source of this problem by issuing the following command at the R command prompt:

    system("ls -ld /usr/local /usr/local/lib /usr/local/lib/libtcl*")
    # ls: /usr/local/lib: Permission denied
    # ls: /usr/local/lib/libtcl*: Permission denied
    # drwx------  8 root  wheel  272 Sep 24 10:21 /usr/local
    

If the output of the system command looks like the above, you should go to Terminal and do the following: sudo chmod -R a+rX /usr/local and enter your password to change directory permissions.

  1. You have an out-dated version of X-Windows. Try running Mac OS Software Update.

It may also be solvable by creating a symbolic link as described in this answer.

This should never come up on Windows, unless you built R from source without tcl/tk support.

The official installation instructions for R say:

Note: the use of X11 (including tcltk) requires XQuartz to be installed since it is no longer part of OS X. Always re-install XQuartz when upgrading your OS X to a new major version.

So: Simply (re)install XQuartz if you want to use the tcltk package in R.

user2669497
  1. delete the X11 file on location : /opt
  2. delete the X11 on application unitiltiy
  3. reinstall X11 again

Problem solved...

For Mac-OS users:

I struggled with this problem recently and found that R-3.1.2 has a bug, which assumes that otool is installed when it is not.

R-3.0.0 (and later) ships with Tck/Tk 8.6.0, so you shouldn't need to install that.

Simply upgrading to a more recent version of R (3.4.2) fixed the problem for me.

I had the same issue and went down a rabbit hole before discovering a simple fix. If you install R from bianry it will include tcltk by default. Just run the installer with the default installation. You can get the .dmg here: https://cran.r-project.org/bin/macosx/

On Arch Linux, tk is a separate package from tcl and both need to be installed:

sudo pacman -S tcl tk

This is given that the output from capabilities("tcltk") with R is TRUE (which means your R is compiled with tcltk support as noted previously in the answers here, this should be the case if you installed it from the arch repos).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!