小编Sot*_*her的帖子

如何在MacOSX上正确卸载numpy?

我在Mac上,我安装numpy,并sklearn按照这个顺序.现在,我遇到了几次已经提到的这些错误:

sklearn"numpy.dtype具有错误的大小,尝试重新编译"pycharm和终端

ValueError:numpy.dtype的大小错误,请尝试重新编译

从sklearn导入时导入:无法导入名称check_build

因此,我尝试通过卸载numpy并重新安装以前的版本来修复此错误.

1)sudo pip install --upgrade numpy..给予权限错误

...OSError: [Errno 1] Operation not permitted: '/tmp/pip-OVY0Vq-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'...

2)我试过了brew uninstall numpy,但是import numpy在shell重启后仍然可以工作.

我能想到的唯一一件事就是手动删除所有numpy文件,这些文件在Mac上可以找到 sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy

....但即便如此,也会给我一个许可错误.是什么赋予了?

python macos numpy python-2.7

25
推荐指数
3
解决办法
6万
查看次数

退出代码和退出状态是否意味着什么火花?

在纱线上运行火花时,我一直看到退出代码和退出状态:

以下是一些:

  • CoarseGrainedExecutorBackend: RECEIVED SIGNAL 15: SIGTERM

  • ...failed 2 times due to AM Container for application_1431523563856_0001_000002 exited with exitCode: 10...

  • ...Exit status: 143. Diagnostics: Container killed on request

  • ...Container exited with a non-zero exit code 52:...

  • ...Container killed on request. Exit code is 137...

我从来没有发现任何这些消息是有用的......有没有机会解释这些消息究竟出了什么问题?我搜索了高低不一的表格来解释错误,但没有.

我能够从上面解释的唯一一个是退出代码52,但那是因为我在这里查看了源代码.这是说这是一个OOM.

我是否应该停止尝试解释其余的退出代码并退出状态?或者我错过了一些明显的方式,这些数字实际意味着什么?

即使有人能告诉我之间的差异exit code,exit status以及SIGNAL这将是有益的.但我现在只是随机猜测,而且我周围的其他所有人都使用了火花.

最后,为什么一些退出代码小于零以及如何解释这些?

例如 Exit status: -100. Diagnostics: Container released on a *lost* node

hadoop hadoop-yarn apache-spark pyspark spark-dataframe

21
推荐指数
1
解决办法
1万
查看次数

如何抑制RStudio中的输出?

当我在RStudio中运行R脚本时,我需要抑制输出.我的脚本中有很多注释,运行文件时会打印注释.

我意识到其他人已经在命令提示符下询问如何执行此操作 - 如何抑制输出.我对此不感兴趣.

我只是想知道如何抑制RStudio中的输出.唯一的例外应该是print陈述.提前致谢.

printing statistics r rgui rstudio

10
推荐指数
1
解决办法
9888
查看次数

如何将参数传递给scikit中只有一部分管道对象学习?

我需要传递一个参数,sample_weightRandomForestClassifier喜欢这样:

X = np.array([[2.0, 2.0, 1.0, 0.0, 1.0, 3.0, 3.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 5.0, 3.0,
        2.0, '0'],
       [15.0, 2.0, 5.0, 5.0, 0.466666666667, 4.0, 3.0, 2.0, 0.0, 0.0, 0.0,
        0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
        7.0, 14.0, 2.0, '0'],
       [3.0, 4.0, 3.0, 1.0, 1.33333333333, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0,
        0.0, 1.0, 0.0, 0.0, 0.0, 0.0, …
Run Code Online (Sandbox Code Playgroud)

python pipeline pandas scikit-learn

10
推荐指数
2
解决办法
5619
查看次数

如何正确卸载python jupyter?

我在我的Mac OSXjupyter安装了,但我想要版本.所以,我基本上需要卸载该版本,并重新安装该版本. python3.5python2.73.52.7

但由于某种原因,我无法卸载3.5版本.我试过了sudo python3 -m pip uninstall jupyter,你可以看到下面的结果:

?  ~/current/directory  
20:08 $ which jupyter
/Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter
?  ~/current/directory  
20:08 $ sudo python3 -m pip uninstall jupyter
The directory '/Users/<username>/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Cannot uninstall requirement jupyter, not …
Run Code Online (Sandbox Code Playgroud)

python ipython jupyter jupyter-notebook

10
推荐指数
1
解决办法
1万
查看次数

如何在vi中找到替换确认时返回到上一个?

经常在我进行查找和替换时,vi我将这样做:

:%s/find/replace/gc
Run Code Online (Sandbox Code Playgroud)

这使您可以选择通过按下跳过n,或按下更换y.但是,有时候n当我打算按下时,我会不小心跳过大文件中的一个y.

我如何回到前一个并给我第二个改变?

从本质上讲,如何I find(search)临时的另一个方向?谢谢.

vi vim

9
推荐指数
2
解决办法
1627
查看次数

为什么我的纱线应用程序即使启用了日志记录也没有日志?

我已经在xml文件中启用了日志: yarn-site.xml然后我重新启动yarn:

sudo service hadoop-yarn-resourcemanager restart
sudo service hadoop-yarn-nodemanager restart
Run Code Online (Sandbox Code Playgroud)

我跑我的应用程序,然后我看到了applicationIDyarn application -list.所以,我这样做: yarn logs -applicationId <application ID>,我得到以下内容:

hdfs://<ip address>/var/log/hadoop-yarn/path/to/application/  does not have any log files
Run Code Online (Sandbox Code Playgroud)

我是否需要更改其他配置?或者我以错误的方式访问日志?

谢谢.

logging hadoop hadoop-yarn apache-spark

8
推荐指数
1
解决办法
9194
查看次数

纱线从属节点不与主节点通信?

我做的时候无法看到我的节点yarn node -list,即使我已经配置/etc/hadoop/conf/yarn-site.xml了正确的属性(在我看来,至少根据这个问题,奴隶节点不在Yarn ResourceManager中).

这是我到目前为止所做的:

  • 安装resourcemanager在主人身上
  • 安装nodemanager在奴隶上
  • yarn-site.xml在所有节点上检查:

    <property> <name>yarn.resourcemanager.hostname</name> <value>master-node</value> </property>

  • 修改配置文件后,重新启动resourcemanagernodemanager分别在主服务器和从服务器上.

但是,当我这样做时,yarn node -list我只能看到

Total Nodes: 0 
Node-Id       Node-state    Node-Http-Address      Number-of-Running-Containers
Run Code Online (Sandbox Code Playgroud)

在我的节点,我查看了.out文件/var/log/hadoop-yarn/,我在其中看到:

ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 244592
max locked memory       (kbytes, -l) 64
max memory …
Run Code Online (Sandbox Code Playgroud)

hadoop hadoop-yarn apache-spark

8
推荐指数
1
解决办法
1026
查看次数

如何使用sympy操纵矩阵中的表达式?

我正在编写一个库,我可以使用库中的对象构造表达式.例如,x并且y是来自我的库的实例,我可以构造如下表达式:

# below is a simplified version of my class 
class MySymbol(object):
    import random
    _random_value = random.randint(1,4)

    def __init__(self, value):
        self.value = value

    def __add__(self, symbol):
        return MySymbol(self.value + symbol.value)

    def __mul__(self, symbol):
        return MySymbol(self.value * symbol.value)

    def __repr__(self):
        return str(self.value)

    def _get_random_value(self):
        return self._random_value

x,y = sympy.symbols('x y')


x = MySymbol(9)
y = MySymbol(3)

import sympy
A = sympy.Matrix([[x,y],[x,y]])
B = sympy.Matrix([[x+y,x*y]])
Run Code Online (Sandbox Code Playgroud)

矩阵运算也是如此.当我希望它们维护它们的类型时,sympy.Matrix该类将这些元素转换为:sympy.core.numbers.IntegerMySymbol

BA=B*A
print type(BA[0,0])
print type(x*x+y*x+x*x*y) # first element …
Run Code Online (Sandbox Code Playgroud)

python oop matrix sympy python-2.7

7
推荐指数
1
解决办法
226
查看次数

如何在Sympy中的矩阵运算中组合多项式?

我正在做一些矩阵运算,有时涉及其条目具有恒定值的矩阵。

但是由于某种原因,即使结果很简单,我也无法通过矩阵运算将结果合并为一个多项式。例如,考虑以下因素:

from sympy.matrices import *
import sympy

x= sympy.symbol.symbols('x')

Poly_matrix = sympy.Matrix([[sympy.Poly(x, x)],[sympy.Poly(x, x)]])
constant_matrix = sympy.Matrix([[0,1]])
constant_matrix_poly = constant_matrix.applyfunc(lambda val: sympy.Poly(val, x))

# this doesn't combine them
result1 = constant_matrix * Poly_matrix
print result1
>>>> Matrix([[Poly(0, x, domain='ZZ') + Poly(x, x, domain='ZZ')]])

# even THIS doesn't combine them when I convert the constants to Polynomials 
result = constant_matrix_poly * Poly_matrix
print result
>>>> Matrix([[Poly(0, x, domain='ZZ') + Poly(x, x, domain='ZZ')]])
Run Code Online (Sandbox Code Playgroud)

问题是,当我尝试提取表达式并将结果转换为其他多项式时,出现以下错误:

# This is where the trouble starts …
Run Code Online (Sandbox Code Playgroud)

python sympy

7
推荐指数
1
解决办法
177
查看次数