Skip to content

Conversation

@MechCoder
Copy link
Contributor

What changes were proposed in this pull request?

I would like to use IPython with Python 3.5. It is annoying when it fails with IPython requires Python 2.7+; please install python2.7 or set PYSPARK_PYTHON when I have a version greater than 2.7

How was this patch tested

It now works with IPython and Python3

@MLnick
Copy link
Contributor

MLnick commented Jun 3, 2016

LGTM

@SparkQA
Copy link

SparkQA commented Jun 4, 2016

Test build #59970 has finished for PR 13503 at commit a051953.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Jun 5, 2016

cc @JoshRosen

@MechCoder
Copy link
Contributor Author

Merge?

@MechCoder
Copy link
Contributor Author

bump?

bin/pyspark Outdated
# Determine the Python executable to use for the executors:
if [[ -z "$PYSPARK_PYTHON" ]]; then
if [[ $PYSPARK_DRIVER_PYTHON == *ipython* && $DEFAULT_PYTHON != "python2.7" ]]; then
if [[ $PYSPARK_DRIVER_PYTHON == *ipython* && $DEFAULT_PYTHON < "python2.7" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the default Python executable is named python but actually points to a Python 2.7+ or Python 3 executable then this is going to return a false positive because the string python is < python2.7.

Rather than relying on the name of the executable, it might make more sense to shell out to Python and ask it its version. For example, I think the following will work:

$DEFAULT_PYTHON -c 'import os; import sys; sys.exit(int(sys.version_info <= (2, 7, 0)))'

If the Python version is greater than or equal to 2.7.0, then this will exit with 0; otherwise, this will exit with 1. This lets you check the exit status and not rely on the executable name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, the code in this PR is a strict improvement over the old overly-stringent check, so it's okay to merge it in its current form but I'd prefer to just make this super robust so we fix this once and for all.

@MechCoder
Copy link
Contributor Author

@JoshRosen fixed, thanks! let me know if you need any other changes.

@MechCoder
Copy link
Contributor Author

I would also like to change

if hash python2.7 2>/dev/null; then
  # Attempt to use Python 2.7, if installed:
  DEFAULT_PYTHON="python2.7"
else
  DEFAULT_PYTHON="python"
fi

to just

DEFAULT_PYTHON="python"

I'm not sure if it is a great assumption that python2.7 is used by default, when python points to something else.

@jodersky
Copy link
Member

lgtm

@SparkQA
Copy link

SparkQA commented Jul 1, 2016

Test build #61578 has finished for PR 13503 at commit 85ce78d.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@MechCoder
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Jul 1, 2016

Test build #61592 has finished for PR 13503 at commit 85ce78d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Jul 1, 2016

Merged to master/2.0/1.6

asfgit pushed a commit that referenced this pull request Jul 1, 2016
…hon3

## What changes were proposed in this pull request?

I would like to use IPython with Python 3.5. It is annoying when it fails with IPython requires Python 2.7+; please install python2.7 or set PYSPARK_PYTHON when I have a version greater than 2.7

## How was this patch tested
It now works with IPython and Python3

Author: MechCoder <[email protected]>

Closes #13503 from MechCoder/spark-15761.

(cherry picked from commit 66283ee)
Signed-off-by: Sean Owen <[email protected]>
@asfgit asfgit closed this in 66283ee Jul 1, 2016
asfgit pushed a commit that referenced this pull request Jul 1, 2016
…hon3

## What changes were proposed in this pull request?

I would like to use IPython with Python 3.5. It is annoying when it fails with IPython requires Python 2.7+; please install python2.7 or set PYSPARK_PYTHON when I have a version greater than 2.7

## How was this patch tested
It now works with IPython and Python3

Author: MechCoder <[email protected]>

Closes #13503 from MechCoder/spark-15761.

(cherry picked from commit 66283ee)
Signed-off-by: Sean Owen <[email protected]>
zzcclp pushed a commit to zzcclp/spark that referenced this pull request Jul 1, 2016
…hon3

## What changes were proposed in this pull request?

I would like to use IPython with Python 3.5. It is annoying when it fails with IPython requires Python 2.7+; please install python2.7 or set PYSPARK_PYTHON when I have a version greater than 2.7

## How was this patch tested
It now works with IPython and Python3

Author: MechCoder <[email protected]>

Closes apache#13503 from MechCoder/spark-15761.

(cherry picked from commit 66283ee)
Signed-off-by: Sean Owen <[email protected]>
(cherry picked from commit 1026aba)
@MechCoder MechCoder deleted the spark-15761 branch July 1, 2016 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants