首页 \ 问答 \ 为Spark安装正确的python版本(Install the right python version for Spark)

为Spark安装正确的python版本(Install the right python version for Spark)

我在我的机器上使用Python 2.7.6

$ python --version
Python 2.7.6

我在我的机器上Spark 1.1.0依赖于Python 2.7.6。 如果我执行:

user@user:~/bin/spark-1.1.0$ ./bin/pyspark

我明白了

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
.
.
.

今天我安装了Spark 1.3.1的新预构建版本(我不知道为什么,但是依赖于python 2.7.5)。 如果我现在为新版本执行相同的命令:

user@user:~/bin/spark-1.3.1-bin-hadoop2.6$ ./bin/pyspark

我找回了旧的Python版本

Python 2.7.5 (default, Jun 18 2014, 09:37:37) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
.
.
.

主要的区别在于,在较旧的Spark版本中,我可以执行import numpy ,而不是新的。

我在.bashrc文件中创建了Python的下一个路径:

export PYTHONPATH=$PYTHONPATH:usr/lib/python2.7

我没有找到在Python中区分版本2.7.6和2.7.5的方法,因此我不知道存储python 2.7.6的地方(缺少命令find )。


I use Python 2.7.6 on my machine

$ python --version
Python 2.7.6

I have on my machine Spark 1.1.0 depended from Python 2.7.6. If I execute:

user@user:~/bin/spark-1.1.0$ ./bin/pyspark

I get

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
.
.
.

Today I install the new pre-built version of Spark 1.3.1 (I don't know why, but depended from python 2.7.5). If I execute now the same command for the new version:

user@user:~/bin/spark-1.3.1-bin-hadoop2.6$ ./bin/pyspark

I get back the older Python version

Python 2.7.5 (default, Jun 18 2014, 09:37:37) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
.
.
.

The main difference is that in the older Spark version I can execute import numpy, in the new one not.

I created the next path for Python in .bashrc file:

export PYTHONPATH=$PYTHONPATH:usr/lib/python2.7

I don't find the way to distinguish between version 2.7.6 and 2.7.5 in Python, thus I don't know a place, where python 2.7.6 is stored (command find is missing).


原文:https://stackoverflow.com/questions/29943042
更新时间:2023-03-28 13:03

最满意答案

每次数据更改时,都应使用notifyDataSetChanged()通知适配器中的这些更改

notifyDataSetChanged():通知附加的观察者基础数据已更改,反映数据集的任何视图都应刷新自身。

喜欢这个:

adapter = new CoursesAdapter(players);
myList.setAdapter(adapter);
....
....
adapter.notifyDataSetChanged();

Every time that your data change you should notify those changes in the adapter, using notifyDataSetChanged()

notifyDataSetChanged(): Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.

like this:

adapter = new CoursesAdapter(players);
myList.setAdapter(adapter);
....
....
adapter.notifyDataSetChanged();

相关问答

更多
  • 解决:我在每个项目中使用ScrollView犯了一个错误(不知不觉), 一个人不能使用Scroll View RecyclerView 项目,因为 RecyclerView滚动。 Solved : I made a mistake (unknowingly) using ScrollView inside each item , One must not use Scroll View into RecyclerView item, because RecyclerView Scrolls Itself.
  • 您不在适配器构造函数中设置数据。 所以,你的数据是空的。 List data = Collections.emptyList(); public MyAdapter(Context context,List data) { inflater=LayoutInflater.from(context); this.data = data; ^^^^^^^^^^^^^^^^ add this state ...
  • 每次数据更改时,都应使用notifyDataSetChanged()通知适配器中的这些更改 notifyDataSetChanged():通知附加的观察者基础数据已更改,反映数据集的任何视图都应刷新自身。 喜欢这个: adapter = new CoursesAdapter(players); myList.setAdapter(adapter); .... .... adapter.notifyDataSetChanged(); Every time that your data change you ...
  • 正如班级名称所说的那样是回收... public class RecyclerViewAdapter extends RecyclerView.Adapter { ArrayList values; SparseBooleanArray expanded = new SparseBooleanArray(); public static class RecViewHolder extends Rec ...
  • 你在这里做错了 public List createlist(){ List data = new ArrayList<>(); for(int i=1; i<=12;i++) { list.add(new Actors("a"+i)); } return data; } 这里是list.add(new Actors("a"+i)); 你在list对象中添加数据但是在return语句中它是return data; 表示 ...
  • 我不能确定这会解决您的问题,但有一件事是不正确的是您如何绑定数据。 tv_country不应该是DataAdapter的一部分; 它应该是每个ViewHolder的一部分。 我们使用ViewHolder模式的原因之一是保持对每行中视图的简单引用。 你的bind方法应该类似于: public void onBindViewHolder(DataAdapter.ViewHolder viewHolder, int i) { viewHolder.tv_country.setText(countries. ...
  • 你尝试过吗? : private boolean isLastItemDisplaying(RecyclerView recyclerView) { if (recyclerView.getAdapter().getItemCount() != 0) { // instead of findLastCompletelyVisibleItemPosition int lastVisibleItemPosition = (( ...
  • 好的,我有你的问题使用这个代码 您的活动布局(activity_main.xml)
    在设置notifyDataSetChanged之前更新getItemCount和您的数据 在您的适配器中: private int mListSize; public void setItemCount(int listsize){ mListSize=listsize; } @Override public int getItemCount() { return mListSize; } 在notifydataset改变之前: if (recyclerViewT1.getAdapter( ...
  • 问题是你永远不会真正改变适配器的列表。 看看Activity类里面的这一行: mFriendsRelation.getQuery().findInBackground(new FindCallback() { @Override public void done(List list, ParseException e) { if (e == null) { mFriends = list; ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)