https://pantsbuild.org/ logo
#general
Title
# general
f

fancy-motherboard-24956

09/16/2020, 2:30 PM
Hi here, I’ve got the most noobish question:
Copy code
./pants --version
Bootstrapping pants_deps with requirements:
  /Users/pchevalier/Documents/code/pants/3rdparty/python/requirements.txt
  /Users/pchevalier/Documents/code/pants/3rdparty/python/twitter/commons/requirements.txt
  /Users/pchevalier/Documents/code/pants/pants-plugins/3rdparty/python/requirements.txt
  /Users/pchevalier/Documents/code/pants/contrib/python/src/python/pants/contrib/python/checks/checker/3rdparty/requirements.txt
Using python at /usr/bin/python3
Using base prefix '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8'
New python executable in /Users/pchevalier/Documents/code/pants/build-support/virtualenvs/Darwin/pants_dev_deps.py38.venv/bin/python3
Also creating executable in /Users/pchevalier/Documents/code/pants/build-support/virtualenvs/Darwin/pants_dev_deps.py38.venv/bin/python
Traceback (most recent call last):
  File "/Users/pchevalier/Documents/code/pants/build-support/virtualenv.dist/virtualenv.py", line 2619, in <module>
    main()
  File "/Users/pchevalier/Documents/code/pants/build-support/virtualenv.dist/virtualenv.py", line 857, in main
    create_environment(
  File "/Users/pchevalier/Documents/code/pants/build-support/virtualenv.dist/virtualenv.py", line 1142, in create_environment
    install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
  File "/Users/pchevalier/Documents/code/pants/build-support/virtualenv.dist/virtualenv.py", line 1607, in install_python
    shutil.copy(original_python, py_executable)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/shutil.py", line 415, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/shutil.py", line 240, in copyfile
    if _samefile(src, dst):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/shutil.py", line 217, in _samefile
    return os.path.samefile(src, dst)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/genericpath.py", line 100, in samefile
    s1 = os.stat(f1)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

Failed to create venv.
h

hundreds-father-404

09/16/2020, 3:28 PM
Looks like a virtualenv issue from what I can tell. Do you want to be using Py38? Generally, you should run pants with Py36 or Py37
f

fancy-motherboard-24956

09/16/2020, 3:39 PM
I’m open-minded 🙂
I guess 3.8 is just the default that gets picked up on my system
h

hundreds-father-404

09/16/2020, 3:40 PM
You can override by setting PY=python3.6 when running pants. See if it makes a difference
f

fancy-motherboard-24956

09/16/2020, 3:43 PM
Thanks a lot @hundreds-father-404,
PY="python3.7" ./pants --version
did the trick 🙂
❤️ 1
h

hundreds-father-404

09/16/2020, 3:44 PM
Ah alternative might be to upgrade virtualenv to something more recent
f

fancy-motherboard-24956

09/16/2020, 3:47 PM
How would you go about this? I tried a few things, but honest: the strange world of python environments is full of mistery to me
h

hundreds-father-404

09/16/2020, 3:47 PM
I think there’s a
virtualenv
script. Bump the version in it
f

fancy-motherboard-24956

09/16/2020, 3:51 PM
Bumping it to the latest version (`20.0.31') leads to a new error:
Copy code
./pants --version
Bootstrapping pants_deps with requirements:
  /Users/pchevalier/Documents/code/pants/3rdparty/python/requirements.txt
  /Users/pchevalier/Documents/code/pants/3rdparty/python/twitter/commons/requirements.txt
  /Users/pchevalier/Documents/code/pants/pants-plugins/3rdparty/python/requirements.txt
  /Users/pchevalier/Documents/code/pants/contrib/python/src/python/pants/contrib/python/checks/checker/3rdparty/requirements.txt
Using python at /usr/bin/python3
Downloading <https://pypi.io/packages/source/v/virtualenv/virtualenv-20.0.31.tar.gz>...
##################################################################################################################################################################################################################################### 100.0%##################################################################################################################################################################################################################################### 100.0%##################################################################################################################################################################################################################################### 100.0%
/Library/Developer/CommandLineTools/usr/bin/python3: can't open file '/Users/pchevalier/Documents/code/pants/build-support/virtualenv.dist/virtualenv.py': [Errno 2] No such file or directory

Failed to create venv
👀 1
My bad
That’s not the latest version of virtualenv
h

hundreds-father-404

09/16/2020, 3:52 PM
Okay, I think that that system Python is pathologically broken from what I can tell. MacOS preinstalled Python is the worst Are you using Pyenv?
f

fancy-motherboard-24956

09/16/2020, 3:53 PM
No. I’m not even sure where this python in /usr/bin/python3 comes from…
Which means I don’t even know how to uninstall it
h

hundreds-father-404

09/16/2020, 3:53 PM
It’s pre-installed and I don’t think safe to uninstall 🙃
f

fancy-motherboard-24956

09/16/2020, 3:53 PM
uhm ok
I’m happy to use the workaround of pointing pants at a non-borked 3.7 for now…
👍 1
h

hundreds-father-404

09/16/2020, 3:55 PM
It might work to brew install Python. Alternatively, brew install pyenv, do pyenv install 3.6.10, then pyenv global 3.6.10. You also have to set up shims in your .bashrc
👍 1
h

happy-kitchen-89482

09/16/2020, 6:50 PM
Yes, I highly recommend NOT using the MacOS system python, it is weirdly broken
👍 2