我正在尝试使用以下指南在伪分布式配置中设置Hadoop版本0.20.203.0:
http://www.javacodegeeks.com/2012/01/hadoop-modes-explained-standalone.html
运行start-all.sh脚本后,我运行"jps".
我得到这个输出:
4825 NameNode
5391 TaskTracker
5242 JobTracker
5477 Jps
5140 SecondaryNameNode
Run Code Online (Sandbox Code Playgroud)
当我尝试使用以下方法向hdfs添加信息时:
bin/hadoop fs -put conf input
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
hadoop@m1a2:~/software/hadoop$ bin/hadoop fs -put conf input
12/04/10 18:15:31 WARN hdfs.DFSClient: DataStreamer Exception: org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /user/hadoop/input/core-site.xml could only be replicated to 0 nodes, instead of 1
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:1417)
at org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock(NameNode.java:596)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:523)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1383)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1379)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:416)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1059)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1377)
at org.apache.hadoop.ipc.Client.call(Client.java:1030)
at …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试使用 pywin32 库将大量数据写入 Excel 电子表格。作为我面临的问题的一个简单示例,请使用以下代码生成 1000 个单元格 x 1000 个单元格的乘法表。
import win32com.client
from win32com.client import constants as c
xl = win32com.client.gencache.EnsureDispatch("Excel.Application")
xl.Visible = True
Workbook = xl.Workbooks.Add()
Sheets = Workbook.Sheets
tableSize = 1000
for i in range(tableSize):
for j in range(tableSize):
Sheets(1).Cells(i+1, j+1).Value = i*j
Run Code Online (Sandbox Code Playgroud)
对于小值,这有效。但是,对于较大的值,python 程序最终会因错误而崩溃:
Traceback (most recent call last):
File ".\Example.py", line 16, in <module>
Sheets(1).Cells(i+1, j+1).Value = i*j
File "C:\PYTHON27\lib\site-packages\win32com\client\__init__.py", line 474, in __setattr__
self._oleobj_.Invoke(*(args + (value,) + defArgs)) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用python编辑povray文件中的单行.
该文件如下所示:
camera {
angle 38
location <500,0,0>
right x*image_width/image_height
look_at <0,0,0>
rotate <0,0,0>
}
Run Code Online (Sandbox Code Playgroud)
我想编辑文件中描述的变量,所以它出现如下:
camera {
angle 38
location <1000,1000,1000>
right x*image_width/image_height
look_at <10,10,10>
rotate <30,30,30>
}
Run Code Online (Sandbox Code Playgroud)
为此,我使用以下方法:
def updateCamera(self, filename):
tmp = "povrayContent/temp.pov"
lines = open(filename, 'r')
out = open(tmp , 'w')
for line in lines:
if " angle" in line:
out.write(" angle "+str(int(self.camAngle))+"\n")
elif " location" in line:
out.write(" location <"+str(int(self.camera[0]))+","+str(int(self.camera[1]))+","+str(int(self.camera[2]))+">\n")
elif " look_at" in line:
out.write(" look_at <"+str(int(self.camera[3]))+","+str(int(self.camera[4]))+","+str(int(self.camera[5]))+">\n")
elif "rotate" in line:
out.write(" rotate <"+str(int(self.camera[6]))+","+str(int(self.camera[7]))+","+str(int(self.camera[8]))+">\n") …Run Code Online (Sandbox Code Playgroud)