OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

TypeError: code() argument 13 must be str, not int

  • Thread starter Thread starter Mahir Shah
  • Start date Start date
M

Mahir Shah

Guest
Code:
C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Scripts\python.exe C:\Users\Admin\PycharmProjects\pysparksetup2\code\RDDCreation_3.py 
Traceback (most recent call last):
  File "C:\Users\Admin\PycharmProjects\pysparksetup2\code\RDDCreation_3.py", line 1, in <module>
    from pyspark.sql import SparkSession
  File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\__init__.py", line 51, in <module>
    from pyspark.context import SparkContext
  File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\context.py", line 30, in <module>
    from pyspark import accumulators
  File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\accumulators.py", line 97, in <module>
    from pyspark.serializers import read_int, PickleSerializer
  File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\serializers.py", line 71, in <module>
    from pyspark import cloudpickle
  File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\cloudpickle.py", line 209, in <module>
    _cell_set_template_code = _make_cell_set_template_code()
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\cloudpickle.py", line 172, in _make_cell_set_template_code
    return types.CodeType(
           ^^^^^^^^^^^^^^^
TypeError: code() argument 13 must be str, not int

Code:
    from pyspark.sql import SparkSession

    if __name__ == '__main__':
        # Step 01 - Create Spark Session
        spark = SparkSession.builder.appName("Spark Demo").master("local").getOrCreate()
        # Step 02 : Create Spark Context
        sc = spark.sparkContext
        # Step 03 : Create RDD by loading the file
        user_rdd = sc.textFile("../dataset/user.csv")

        # Print Top 5 records
        for record in user_rdd.take(5):
            print(record)
<pre><code>C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Scripts\python.exe C:\Users\Admin\PycharmProjects\pysparksetup2\code\RDDCreation_3.py
Traceback (most recent call last):
File "C:\Users\Admin\PycharmProjects\pysparksetup2\code\RDDCreation_3.py", line 1, in <module>
from pyspark.sql import SparkSession
File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\__init__.py", line 51, in <module>
from pyspark.context import SparkContext
File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\context.py", line 30, in <module>
from pyspark import accumulators
File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\accumulators.py", line 97, in <module>
from pyspark.serializers import read_int, PickleSerializer
File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\serializers.py", line 71, in <module>
from pyspark import cloudpickle
File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\cloudpickle.py", line 209, in <module>
_cell_set_template_code = _make_cell_set_template_code()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Admin\PycharmProjects\pysparksetup2\venv\Lib\site-packages\pyspark\cloudpickle.py", line 172, in _make_cell_set_template_code
return types.CodeType(
^^^^^^^^^^^^^^^
TypeError: code() argument 13 must be str, not int
</code></pre>
<pre><code> from pyspark.sql import SparkSession

if __name__ == '__main__':
# Step 01 - Create Spark Session
spark = SparkSession.builder.appName("Spark Demo").master("local").getOrCreate()
# Step 02 : Create Spark Context
sc = spark.sparkContext
# Step 03 : Create RDD by loading the file
user_rdd = sc.textFile("../dataset/user.csv")

# Print Top 5 records
for record in user_rdd.take(5):
print(record)

</code></pre>
 

Latest posts

Top