<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: topology.py not Python 3 compatible in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/83524#M54397</link>
    <description>&lt;P&gt;One easy option in old CDH versions is just to change the shebang at the beginning of the script to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/usr/bin/env python2&lt;/PRE&gt;&lt;P&gt;Actually this will be more precise than the default, because the script is actually a python 2 script and ... python 3 is coming ... so it is good to be specific about the given version of the interpreter the script needs. We could be even more explicit and require python2.7.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Dec 2018 17:23:16 GMT</pubDate>
    <dc:creator>javicacheiro</dc:creator>
    <dc:date>2018-12-10T17:23:16Z</dc:date>
    <item>
      <title>topology.py not Python 3 compatible</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/50900#M54392</link>
      <description>&lt;P&gt;I don't know who's responsible for writing topology.py, but it uses Python 2 syntax, so if I try to run PySpark with Python 3 using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;export PYSPARK_PYTHON=python3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I get tons of stacktraces.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Uri&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 11:05:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/50900#M54392</guid>
      <dc:creator>urilaserson</dc:creator>
      <dc:date>2022-09-16T11:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: topology.py not Python 3 compatible</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/50901#M54393</link>
      <description>This was fixed in CM 5.9.</description>
      <pubDate>Tue, 14 Feb 2017 18:50:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/50901#M54393</guid>
      <dc:creator>Darren</dc:creator>
      <dc:date>2017-02-14T18:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: topology.py not Python 3 compatible</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/50904#M54394</link>
      <description>&lt;P&gt;Any workaround for earlier versions? &amp;nbsp;I'm on 5.5 and I don't&amp;nbsp;manage the cluster.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 20:44:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/50904#M54394</guid>
      <dc:creator>urilaserson</dc:creator>
      <dc:date>2017-02-14T20:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: topology.py not Python 3 compatible</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/50914#M54395</link>
      <description>&lt;P&gt;Depending on how you are running the job, you may be able to override the topology script parameter and/or replace the toplogy.py script with one that is python 3 compatible.&amp;nbsp;If you're submitting jobs from the command line, you'd usually copy /etc/hadoop/conf to some custom directory /path/to/customized/conf, make changes there, then set HADOOP_CONF_DIR=/path/to/customized/conf and run your job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming you can change that topology script, here's the relevant portion of the diff that you can apply:&lt;/P&gt;&lt;PRE&gt;@@ -1,8 +1,8 @@
#!/usr/bin/env python
#
-# Copyright (c) 2010-2012 Cloudera, Inc. All rights reserved.
+# Copyright (c) 2016 Cloudera, Inc. All rights reserved.
#
- 
+
'''
This script is provided by CMF for hadoop to determine network/rack topology.
It is automatically generated and could be replaced at any time. Any changes
@@ -12,8 +12,13 @@ made to it will be lost when this happens.
import os
import sys
import xml.dom.minidom
-from string import join
- 
+
+try:
+ xrange
+except NameError:
+ # support for python3, which basically renamed xrange to range
+ xrange = range
+
def main():
MAP_FILE = '{{CMF_CONF_DIR}}/topology.map'
DEFAULT_RACK = '/default'
@@ -40,14 +45,14 @@ def main():
map[node.getAttribute("name")] = node.getAttribute("rack")
except:
default_rack = "".join([ DEFAULT_RACK for _ in xrange(max_elements)])
- print default_rack
+ print(default_rack)
return -1
- 
+
default_rack = "".join([ DEFAULT_RACK for _ in xrange(max_elements)])
if len(sys.argv)==1:
- print default_rack
+ print(default_rack)
else:
- print join([map.get(i, default_rack) for i in sys.argv[1:]], " ")
+ print(" ".join([map.get(i, default_rack) for i in sys.argv[1:]]))
return 0

if __name__ == "__main__":&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 00:16:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/50914#M54395</guid>
      <dc:creator>Darren</dc:creator>
      <dc:date>2017-02-15T00:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: topology.py not Python 3 compatible</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/82141#M54396</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I'm cluster manager,and CDH version is 5.7.2.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; The same trouble,If I can change some params in CM to solve this problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 02:02:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/82141#M54396</guid>
      <dc:creator>zbz</dc:creator>
      <dc:date>2018-11-09T02:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: topology.py not Python 3 compatible</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/83524#M54397</link>
      <description>&lt;P&gt;One easy option in old CDH versions is just to change the shebang at the beginning of the script to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/usr/bin/env python2&lt;/PRE&gt;&lt;P&gt;Actually this will be more precise than the default, because the script is actually a python 2 script and ... python 3 is coming ... so it is good to be specific about the given version of the interpreter the script needs. We could be even more explicit and require python2.7.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 17:23:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/topology-py-not-Python-3-compatible/m-p/83524#M54397</guid>
      <dc:creator>javicacheiro</dc:creator>
      <dc:date>2018-12-10T17:23:16Z</dc:date>
    </item>
  </channel>
</rss>

