Check if macOS has a python2 symlink pointing to most up-to-date python2 version
This issue is related to Python3 porting. In L-367 there is a call from the workers either with python2 or python3. Probably, on macOS such python2 symlink does not exist.
Comments (12)
-
repo owner -
repo owner Can we get the right command from
sys.exectuable
? E.g., on my machine:$ python -c "import sys; print(sys.executable)" /usr/bin/python $ python2 -c "import sys; print(sys.executable)" /usr/bin/python2 $ python2.7 -c "import sys; print(sys.executable)" /usr/bin/python2.7
-
repo owner Also works in python3 (forgot to list):
$ python3 -c "import sys; print(sys.executable)" /usr/bin/python3
-
reporter This would be a dynamic way to set the
workercommand
. When I leave the office for going home, I will test it on my macOS (and some 'vanilla' virtual box images of macOS I have) and will report back. -
repo owner Might also be worth trying on Windows, as that's odder than Macs for these applications. But from the python documentation for sys.executable, it sounds like this should work in general...
-
reporter I have created a commit with the changes below and seems to be working well on macOS and Linux:
± % !10145 diff --git a/amp/model/__init__.py b/amp/model/__init__.py index 02ff5ce..4b62144 100755 --- a/amp/model/__init__.py +++ b/amp/model/__init__.py @@ -365,10 +365,8 @@ class LossFunction: self.images = self._model.trainingparameters.trainingimages if self._parallel['cores'] != 1: # Initialize workers. - if sys.version_info[0] == 2: # Check Python2 or Python3. - workercommand = 'python2 -m %s' % self.__module__ - else: - workercommand = 'python3 -m %s' % self.__module__ + python = sys.executable + workercommand = '%s -m %s' % (python, self.__module__) server, connections, n_pids = setup_parallel(self._parallel, workercommand, log) self._sessions = {'master': server, diff --git a/amp/utilities.py b/amp/utilities.py index c958b69..1742250 100644 --- a/amp/utilities.py +++ b/amp/utilities.py @@ -424,10 +424,8 @@ class Data: d.close() # Necessary to get out of write mode and unlock? log(' Calculated %i new images.' % len(calcs_needed)) else: - if sys.version_info[0] == 2: # Python2 or Python3. - workercommand = 'python2 -m %s' % self.calc.__module__ - else: - workercommand = 'python3 -m %s' % self.calc.__module__ + python = sys.executable + workercommand = '%s -m %s' % (python, self.calc.__module__) server, connections, n_pids = setup_parallel(parallel, workercommand, log)
If you agree, I will push it to
master
and close this report. I also suppose that it should work on Windows becausesys
is cross-platform. -
repo owner Looks good. Go for it.
-
reporter In this commit, we dynamically check for the python interpreter absolute PATH to be used by the workercommand. Closes issue
#171.→ <<cset aec0cdb8d3d0>>
-
reporter Merge branch 'master' into krr
- master: (42 commits)
Amp requires matplotlib > 1.5.0. I have added this information on installation.rst.
Update release notes.
Update release instructions.
Add DOI for v0.6.
Remove Neural reference.
Clarify release documentation.
Update latest stable on docs index.
Sync release notes to 0.6.
Clarify release instructions.
Fix name error in tflow test.
Update test docs / names.
Remove debug logging from last commit.
Change worker count.
Decide whether to skip tflow tests.
Small clean-up.
Fix test; loosen tolerance.
Remove logging from last commit.
Fixes to Zernike test.
In this commit, we dynamically check for the python interpreter absolute PATH to be used by the workercommand. Closes issue
#171. Eliminate dependency on nose timer. ...
→ <<cset f1a8ac97f625>>
- master: (42 commits)
Amp requires matplotlib > 1.5.0. I have added this information on installation.rst.
Update release notes.
Update release instructions.
Add DOI for v0.6.
Remove Neural reference.
Clarify release documentation.
Update latest stable on docs index.
Sync release notes to 0.6.
Clarify release instructions.
Fix name error in tflow test.
Update test docs / names.
Remove debug logging from last commit.
Change worker count.
Decide whether to skip tflow tests.
Small clean-up.
Fix test; loosen tolerance.
Remove logging from last commit.
Fixes to Zernike test.
In this commit, we dynamically check for the python interpreter absolute PATH to be used by the workercommand. Closes issue
-
reporter Merge branch 'master' into krr
- master: (42 commits)
Amp requires matplotlib > 1.5.0. I have added this information on installation.rst.
Update release notes.
Update release instructions.
Add DOI for v0.6.
Remove Neural reference.
Clarify release documentation.
Update latest stable on docs index.
Sync release notes to 0.6.
Clarify release instructions.
Fix name error in tflow test.
Update test docs / names.
Remove debug logging from last commit.
Change worker count.
Decide whether to skip tflow tests.
Small clean-up.
Fix test; loosen tolerance.
Remove logging from last commit.
Fixes to Zernike test.
In this commit, we dynamically check for the python interpreter absolute PATH to be used by the workercommand. Closes issue
#171. Eliminate dependency on nose timer. ...
→ <<cset f1a8ac97f625>>
- master: (42 commits)
Amp requires matplotlib > 1.5.0. I have added this information on installation.rst.
Update release notes.
Update release instructions.
Add DOI for v0.6.
Remove Neural reference.
Clarify release documentation.
Update latest stable on docs index.
Sync release notes to 0.6.
Clarify release instructions.
Fix name error in tflow test.
Update test docs / names.
Remove debug logging from last commit.
Change worker count.
Decide whether to skip tflow tests.
Small clean-up.
Fix test; loosen tolerance.
Remove logging from last commit.
Fixes to Zernike test.
In this commit, we dynamically check for the python interpreter absolute PATH to be used by the workercommand. Closes issue
-
reporter Merge branch 'master' into krr
- master: (42 commits)
Amp requires matplotlib > 1.5.0. I have added this information on installation.rst.
Update release notes.
Update release instructions.
Add DOI for v0.6.
Remove Neural reference.
Clarify release documentation.
Update latest stable on docs index.
Sync release notes to 0.6.
Clarify release instructions.
Fix name error in tflow test.
Update test docs / names.
Remove debug logging from last commit.
Change worker count.
Decide whether to skip tflow tests.
Small clean-up.
Fix test; loosen tolerance.
Remove logging from last commit.
Fixes to Zernike test.
In this commit, we dynamically check for the python interpreter absolute PATH to be used by the workercommand. Closes issue
#171. Eliminate dependency on nose timer. ...
→ <<cset f1a8ac97f625>>
- master: (42 commits)
Amp requires matplotlib > 1.5.0. I have added this information on installation.rst.
Update release notes.
Update release instructions.
Add DOI for v0.6.
Remove Neural reference.
Clarify release documentation.
Update latest stable on docs index.
Sync release notes to 0.6.
Clarify release instructions.
Fix name error in tflow test.
Update test docs / names.
Remove debug logging from last commit.
Change worker count.
Decide whether to skip tflow tests.
Small clean-up.
Fix test; loosen tolerance.
Remove logging from last commit.
Fixes to Zernike test.
In this commit, we dynamically check for the python interpreter absolute PATH to be used by the workercommand. Closes issue
-
reporter Merge branch 'master' into krr
- master: (42 commits)
Amp requires matplotlib > 1.5.0. I have added this information on installation.rst.
Update release notes.
Update release instructions.
Add DOI for v0.6.
Remove Neural reference.
Clarify release documentation.
Update latest stable on docs index.
Sync release notes to 0.6.
Clarify release instructions.
Fix name error in tflow test.
Update test docs / names.
Remove debug logging from last commit.
Change worker count.
Decide whether to skip tflow tests.
Small clean-up.
Fix test; loosen tolerance.
Remove logging from last commit.
Fixes to Zernike test.
In this commit, we dynamically check for the python interpreter absolute PATH to be used by the workercommand. Closes issue
#171. Eliminate dependency on nose timer. ...
→ <<cset f1a8ac97f625>>
- master: (42 commits)
Amp requires matplotlib > 1.5.0. I have added this information on installation.rst.
Update release notes.
Update release instructions.
Add DOI for v0.6.
Remove Neural reference.
Clarify release documentation.
Update latest stable on docs index.
Sync release notes to 0.6.
Clarify release instructions.
Fix name error in tflow test.
Update test docs / names.
Remove debug logging from last commit.
Change worker count.
Decide whether to skip tflow tests.
Small clean-up.
Fix test; loosen tolerance.
Remove logging from last commit.
Fixes to Zernike test.
In this commit, we dynamically check for the python interpreter absolute PATH to be used by the workercommand. Closes issue
- Log in to comment
Muammar's email:
I think that this is ready for a first debian release. I was checking on https://bitbucket.org/andrewpeterson/amp/issues/171/check-if-macos-has-a-python2-symlink#comment-None and I found that macOS only ships with the following python symlinks: python, python2.7 and python2.5.X (where X is any minor version). It seems that only Linux distributions ship with python2 and python3 symlinks in /usr/bin/. Then, what should we do about the
workercommand
?1) Leave it just as python, and then let the OS decide which version is used to run Amp. 2) Rename it from python2, to python2.7?. Amp's documentation suggests that Python 2.7 is recommended. However, the problem still remains with different python3 versions. 3) Append to the documentation for macOS users that they will need to create a symlink pointing their python2.X.Y/3.X.Y to /usr/loca/bin/python2/3.