You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "gwdgithubnom (via GitHub)" <gi...@apache.org> on 2025/07/03 07:29:23 UTC

[PR] [SPARK-52669][ PySpark]Resolve the issue where PySpark fails to run due to different Python minor versions. Run Python directly. [spark]

gwdgithubnom opened a new pull request, #51357:
URL: https://github.com/apache/spark/pull/51357

   
   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   This PR fixes a Python version mismatch issue in PySpark cluster execution. The problem occurred when running PySpark jobs in YARN client mode where the driver and executors had different Python minor versions (eg: 3.10 vs 3.6), causing runtime errors. The fix ensures consistent Python versions by:
   
   1. use old strategy to read current os.environ, if none try use spark conf variable "spark.pyspark.driver.python" and "spark.pyspark.python",  to keep the driver and executor could use the same Python interpreter from the archived environment (eg: ./environment/bin/python). 
   
   2. Verifying the Python version consistency through RDD operations that report executor environments.
   
   The solution was tested by running the sample run.py script which now correctly reports matching Python versions across driver and executors.
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   PySpark requires driver and executors to use compatible Python versions (same minor version).  If we not changes, to run in python dev environment, need for all scripts define export PYSPARK_PYTHON env.
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
   
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   
   ### How was this patch tested?
   Testing steps:
   
   1. Deployed the fixed configuration in YARN client mode
   
   2. Ran the sample run.py script with:
   
   ```
   spark.range(1).rdd.map(lambda x: (x, 
      f"Executor Python version: {sys.version}",
      f"#Executor Python executable: {sys.executable}")).collect()
   ```
   3 Verified:
   
   - Driver and executor Python versions match in output
   - No RuntimeError occurs
   - UI shows correct environment configuration
   
   Additional verification:
   
   Tested with both working and broken configurations to confirm error cases
   Validated archive path resolution (#environment) works as expected
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-52669][PySpark]Improvement PySpark choose pythonExec in cluster yarn client mode [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #51357: [SPARK-52669][PySpark]Improvement PySpark choose pythonExec in cluster yarn client mode
URL: https://github.com/apache/spark/pull/51357


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-52669][PySpark]Improvement PySpark choose pythonExec in cluster yarn client mode [spark]

Posted by "gwdgithubnom (via GitHub)" <gi...@apache.org>.
gwdgithubnom commented on PR #51357:
URL: https://github.com/apache/spark/pull/51357#issuecomment-3301557174

   @HyukjinKwon request a review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-52669][PySpark]Improvement PySpark choose pythonExec in cluster yarn client mode [spark]

Posted by "gwdgithubnom (via GitHub)" <gi...@apache.org>.
gwdgithubnom commented on PR #51357:
URL: https://github.com/apache/spark/pull/51357#issuecomment-3159551419

   Hi @HyukjinKwon, cc @dongjoon-hyun @cloud-fan @holdenk @jose-torres, please following up on my PR.
   
   It fixes a critical Python version mismatch in PySpark client mode (**non-YARN**) where `PYSPARK_PYTHON` may not be set. The solution uses `spark.pyspark.python` and `spark.pyspark.driver.python` for reliable interpreter resolution.
   
   I know you're busy, but a quick review would be great. Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-52669][PySpark]Improvement PySpark choose pythonExec in cluster yarn client mode [spark]

Posted by "gwdgithubnom (via GitHub)" <gi...@apache.org>.
gwdgithubnom commented on PR #51357:
URL: https://github.com/apache/spark/pull/51357#issuecomment-3047716792

   Hi @HyukjinKwon,could you please take a look at this PR when you have time?  It's related to the pyspark module (context.py).
   When we run mode with client  mode, the driver and executor would throws a "python version" error. During Spark context initialization in local/client mode (non-YARN deployment), the launch_container.sh script - which typically sets the PYSPARK_PYTHON environment variable - would not be executed. Consequently, this critical environment variable may remain unset on the client node.
   
   To address this, we should implement a more robust Python interpreter resolution mechanism that:
   
   1. First checks Spark configuration parameters (spark.pyspark.driver.python for driver-specific configuration and spark.pyspark.python for shared configuration)
   2. Only falls back to the default "python3" if no valid configuration is found
   
   The implementation should prioritize configuration over environment variables, as Spark's configuration system provides a more reliable and explicit way to manage such settings across different deployment environments.
   
   ![image](https://github.com/user-attachments/assets/52dd363a-2a35-4de0-b709-d5ff9cd45188)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-52669][PySpark]Improvement PySpark choose pythonExec in cluster yarn client mode [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #51357:
URL: https://github.com/apache/spark/pull/51357#issuecomment-3693516622

   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org