我刚刚安装了Anaconda 3.5.终端显示正确的版本,甚至括号内的Continuum Analytics:
Python 3.5.0 |Continuum Analytics, Inc.| (default, Oct 20 2015, 14:39:26)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Run Code Online (Sandbox Code Playgroud)
但是,当我键入以下内容时:
>>> import numpy
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
Run Code Online (Sandbox Code Playgroud)
我知道Anaconda带有numpy(我跑了conda list,只是为了确定).有谁知道发生了什么?
似乎我可能.bash_profile与它有关.如果是,则内容如下.
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# added by Anaconda3 2.3.0 …Run Code Online (Sandbox Code Playgroud) 我正在使用该wikipedia库,并且想将其DisambiguationError作为异常处理。我的第一次尝试是
try:
wikipedia.page('equipment') # could be any ambiguous term
except DisambiguationError:
pass
Run Code Online (Sandbox Code Playgroud)
在执行期间,未到达第 3 行。一个更普遍的问题是:如何找到这样的特定于库的类的错误类型?
从R,我正在尝试运行sourceCpp此文件:
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace arma;
using namespace Rcpp;
// [[Rcpp::export]]
vec dnormLog(vec x, vec means, vec sds) {
int n = x.size();
vec res(n);
for(int i = 0; i < n; i++) {
res[i] = log(dnorm(x[i], means[i], sds[i]));
}
return res;
}
Run Code Online (Sandbox Code Playgroud)
看到这个答案,看看我从哪里获得了这个功能.这会引发错误:
no matching function for call to 'dnorm4'
这是我希望通过使用循环来防止的确切错误,因为引用的答案提到dnorm仅针对其第一个参数进行向量化.我担心答案是显而易见的,但我尝试R::在之前添加dnorm,尝试使用NumericVector而不是在前面vec使用log().没运气.但是,R::之前添加dnorm会产生单独的错误:
too few arguments to …Run Code Online (Sandbox Code Playgroud)