我最近将R更新为3.1.0。我试图将我的软件包移到R.Framework里面的3.1(我正在运行OSX Mavericks)并且不知何故弄得一团糟,所以在干净安装之前完全卸载了所有东西。
在重新安装软件包时,我遇到问题,直到我点击forecast
软件包,产生以下错误:
package ‘forecast’ is available as a source package but not as a binary
Warning in install.packages :
package ‘forecast’ is not available (for R version 3.1.0)
我实际上有R 3.1.0并且在重新安装之前预测和hts一起工作所以我怀疑问题源于我已经完成的事情,而不是兼容性问题。
我运行了以下内容,看看是否可以发现有关安装失败的更多详细信息:install.packages("forecast", type = "source", verbose = T, quiet = F)
其输出略高于我,但可能有助于诊断:
system (cmd0): /Library/Frameworks/R.framework/Resources/bin/R CMD INSTALL
trying URL 'http://cran.rstudio.com/src/contrib/forecast_5.3.tar.gz'
Content type 'application/x-gzip' length 150395 bytes (146 Kb)
opened URL
==================================================
downloaded 146 Kb
foundpkgs: forecast, /var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T//RtmpzTzSpG/downloaded_packages/forecast_5.3.tar.gz
files: /var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T//RtmpzTzSpG/downloaded_packages/forecast_5.3.tar.gz
* installing *source* package ‘forecast’ ...
** package ‘forecast’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c calcBATS.cpp -o calcBATS.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c calcTBATS.cpp -o calcTBATS.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c etsTargetFunction.cpp -o etsTargetFunction.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c etsTargetFunctionWrapper.cpp -o etsTargetFunctionWrapper.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c etscalc.c -o etscalc.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c etspolyroot.c -o etspolyroot.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c makeBATSMatrices.cpp -o makeBATSMatrices.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c makeTBATSMatrices.cpp -o makeTBATSMatrices.o
makeTBATSMatrices.cpp:11:6: warning: unused variable 'lengthSeasonal' [-Wunused-variable]
int lengthSeasonal = 0;
^
1 warning generated.
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c updateMatrices.cpp -o updateMatrices.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -Wall -mtune=core2 -g -O2 -c updateTBATSMatrices.cpp -o updateTBATSMatrices.o
updateTBATSMatrices.cpp:38:10: warning: unused variable 'gammaVector' [-Wunused-variable]
double *gammaVector;
^
1 warning generated.
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o forecast.so calcBATS.o calcTBATS.o etsTargetFunction.o etsTargetFunctionWrapper.o etscalc.o etspolyroot.o makeBATSMatrices.o makeTBATSMatrices.o updateMatrices.o updateTBATSMatrices.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [forecast.so] Error 1
ERROR: compilation failed for package ‘forecast’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/forecast’
Warning in install.packages :
installation of package ‘forecast’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/0y/_13fkvws0tn5xh4m8wsymkdh0000gp/T/RtmpzTzSpG/downloaded_packages’
我非常感谢这里的一些帮助。我最近一直在研究的大部分代码都依赖于预测中的功能。
答案 0 :(得分:3)
这是我做的(RcppArmadillo Compile Errors on OS X Mavericks)
从brew安装gfortran(如果你没有酿造,谷歌吧。安装很简单):
brew install gfortran
如果已安装,请使用以下命令升级到最新版本:
brew upgrade gfortran
然后执行以下操作之一:
ln -s /usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgfortran.* /usr/local/lib/
或将此行添加到~/.R/Makevars
文件中:
FLIBS=-L/usr/local/Cellar/gfortran/4.8.2/gfortran
我做了第二个选择。
现在再次运行install.packages("forecast", type = "source")
,它应该有效。
答案 1 :(得分:1)
终端
Rstudio:
答案 2 :(得分:0)
从https://gcc.gnu.org/wiki/GFortranBinariesMacOS
下载gfortransudo rm -r / usr / local / gfortran / usr / local / bin / gfortran
然后安装gfortran
sudo vi /Library/Frameworks/R.framework/Resources/etc/Makeconf
将所有gfortran-4.8更改为gfortran
FC = gfortran FCFLAGS = -Wall -g -O2 $(LTO) FCLIBS = F77 = gfortran F77_VISIBILITY = FFLAGS = -g -O2 $(LTO)
FLIBS = -L / usr / local / lib / gcc / x86_64-apple-darwin13.0.0 / 4.8.2 -lgfortran -lquadmath -lm答案 3 :(得分:0)
要安装gfortran,请使用
# --- Import des bibliothèques utilisées (dont pygame) ---
import pygame
from pygame import*
from pygame.locals import *
pygame.init()
from random import *
# --- Classe du jeu ---
class Jeux:
def __init__(self):
# generer notre joueur
self.all_players = pygame.sprite.Group()
self.player = Player()
self.all_players.add(self.player)
# groupe de cible
self.all_cibles = pygame.sprite.Group()
self.all_projectiles = pygame.sprite.Group()
self.pressed = {}
# --- Classe du joueur ---
class Player(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.attack = 10
self.velocity = 7
"""self.all_players = pygame.sprite.Group()
self.all_projectiles = pygame.sprite.Group()"""
self.image = pygame.image.load("F:/ISN/game/ressource/vaisseau1.png")
self.rect = self.image.get_rect()
self.rect.x = 0
self.rect.y = 600
def launch_projectile(self):
game.all_projectiles.add(Projectile(self, game))
def launch_cible(self):
game.all_cibles.add(Cible(self, game))
# fonction pour aller a droite
def move_right(self):
self.rect.x += self.velocity
# fonction pour aller a gauche
def move_left(self):
self.rect.x -= self.velocity
# --- Classe du projectile ---
class Projectile(pygame.sprite.Sprite):
def __init__(self, player, game):
super().__init__()
self.velocity = 7
self.game = game
self.player = player
self.image = pygame.image.load("F:/ISN/game/ressource/projectile-png-2.png")
self.image = pygame.transform.scale(self.image, (10, 20))
self.rect = self.image.get_rect()
self.game.all_projectiles.add(self)
self.rect.x = player.rect.x + 59
self.rect.y = player.rect.y
# fonction servant à détruire le projectile quand il est hors de la fenêtre
def remove_projectile(self):
self.game.all_projectiles.remove(self)
def move(self):
self.rect.y -= self.velocity
# vérifier si notre projectile n'est plus présent sur l'écran
if self.rect.y < 0:
# supprimer le projectile
self.remove_projectile()
# --- Classe de la cible ---
class Cible(pygame.sprite.Sprite):
def __init__(self, player, game):
super().__init__()
self.game = game
self.image = pygame.image.load("F:/ISN/game/ressource/catalan.png")
self.image = pygame.transform.scale(self.image, (40, 40))
self.rect = self.image.get_rect()
self.game.all_cibles.add(self)
self.rect.x = randint(50, 1000)
self.rect.y = randint(0, 400)
def remove_cible(self):
self.game.all_cibles.remove(self)
# --- Gestion des touches et de la fenêtre de jeu ---
clock = pygame.time.Clock()
# generer la fenetre du jeu
pygame.display.set_caption("SPACE INVADERS V2")
screen = pygame.display.set_mode((1080, 720))
# importer charger l'arriere plan
background = pygame.image.load("F:/ISN/game/ressource/BACKGROUND.jpg")
# charger notre jeu
game = Jeux()
running = True
# boucle tant que cette condition est vrai
while running:
# appliquer l'arriere plan de notre jeu
screen.blit(background, (0, 0))
# appliquer l'image de notre joueur sur la fenetre de jeu
screen.blit(game.player.image, game.player.rect)
# afficher la cible
game.all_cibles.draw(screen)
# recuperer les projectiles du joueur
for projectile in game.all_projectiles:
projectile.move()
# appliquer l'ensemble des images de mon groupe de projectiles
game.all_projectiles.draw(screen)
# mouvements du joueur
if game.pressed.get(pygame.K_RIGHT) and game.player.rect.x + game.player.rect.width < screen.get_width():
game.player.move_right()
elif game.pressed.get(pygame.K_LEFT) and game.player.rect.x > 0:
game.player.move_left()
# mettre a jour l'ecran
pygame.display.flip()
# si le joueur ferme cette fenetre
for event in pygame.event.get():
# que l'evenement est fermeture de fenetre
if event.type == pygame.QUIT:
running = False
pygame.quit()
print("Fermeture du jeu")
# detecter si un joueur lache une touche du clavier
elif event.type == pygame.KEYDOWN:
game.pressed[event.key] = True
if event.key == pygame.K_SPACE:
game.player.launch_projectile()
elif event.key == pygame.K_DOWN:
game.player.launch_cible()
elif event.type == pygame.KEYUP:
game.pressed[event.key] = False
collisions = pygame.sprite.groupcollide(game.all_projectiles, game.all_cibles, False, True)
if collisions:
print('collision')
if pygame.sprite.spritecollide(game.player, game.all_projectiles, False):
print('Collide')