python-poetry / install.python-poetry.org

The official Poetry installation script
https://install.python-poetry.org
204 stars 54 forks source link

Installation on Python from Xcode Command Line Tools #67

Open ghost opened 3 years ago

ghost commented 3 years ago

Issue

Hello everyone, I'm having some trouble with Poetry recently, although I work with Python for some years. On a clean macOS install, with only Command Line Tools from Apple installed, we get Python 3.8.2 with some outdated Pip. Installing Poetry with this Pip version (19) breaks beautifully, but after an --user --upgrade pip I got it working.

The problem is: when using the official installer curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python3 - I got:

Retrieving Poetry metadata
# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:
/Users/mateus/Library/Python/3.8/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (1.1.8): Done
Poetry (1.1.8) is installed now. Great!

You can test that everything is set up by executing:
`poetry --version`

Everything seems fine, my PATH is already good:

echo $PATH
/Users/mateus/Library/Python/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

But trying poetry I get zsh: command not found: poetry. 😢 Upon further investigation, we can see that poetry is a symlink under my "Poetry bin directory":

ll /Users/mateus/Library/Python/3.8/bin

-rwxr-xr-x  1 mateus  staff   251B  5 Set 12:45 doesitcache
-rwxr-xr-x  1 mateus  staff   245B  5 Set 12:45 keyring
-rwxr-xr-x  1 mateus  staff   279B  5 Set 12:45 normalizer
-rwxr-xr-x  1 mateus  staff   259B  5 Set 12:41 pip
-rwxr-xr-x  1 mateus  staff   259B  5 Set 12:41 pip3
-rwxr-xr-x  1 mateus  staff   259B  5 Set 12:41 pip3.8
-rwxr-xr-x  1 mateus  staff   253B  5 Set 12:45 pkginfo
lrwxr-xr-x  1 mateus  staff    66B  5 Set 12:45 poetry -> /Users/mateus/Library/Application Support/pypoetry/venv/bin/poetry
-rwxr-xr-x  1 mateus  staff   273B  5 Set 12:45 virtualenv
-rwxr-xr-x  1 mateus  staff   246B  5 Set 12:41 wheel

Okay, so lets check what's on /Users/mateus/Library/Application Support/pypoetry/venv/bin/:

ll /Users/mateus/Library/Application\ Support/pypoetry/venv/bin 

-rw-r--r--  1 mateus  staff   2,1K  5 Set 12:45 activate
-rw-r--r--  1 mateus  staff   1,4K  5 Set 12:45 activate.csh
-rw-r--r--  1 mateus  staff   3,0K  5 Set 12:45 activate.fish
-rw-r--r--  1 mateus  staff   1,7K  5 Set 12:45 activate.ps1
-rw-r--r--  1 mateus  staff   1,2K  5 Set 12:45 activate_this.py
-rwxr-xr-x  1 mateus  staff   306B  5 Set 12:45 pip
-rwxr-xr-x  1 mateus  staff   306B  5 Set 12:45 pip-3.8
-rwxr-xr-x  1 mateus  staff   306B  5 Set 12:45 pip3
-rwxr-xr-x  1 mateus  staff   306B  5 Set 12:45 pip3.8
lrwxr-xr-x  1 mateus  staff   128B  5 Set 12:45 python -> /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python
lrwxr-xr-x  1 mateus  staff     6B  5 Set 12:45 python3 -> python
lrwxr-xr-x  1 mateus  staff     6B  5 Set 12:45 python3.8 -> python
-rwxr-xr-x  1 mateus  staff   293B  5 Set 12:45 wheel
-rwxr-xr-x  1 mateus  staff   293B  5 Set 12:45 wheel-3.8
-rwxr-xr-x  1 mateus  staff   293B  5 Set 12:45 wheel3
-rwxr-xr-x  1 mateus  staff   293B  5 Set 12:45 wheel3.8

As you can see, no signal whatsoever of poetry on Library/Application\ Support/pypoetry/venv/bin, and I really don't understand why. Anyone have any clues?

Already tried a complete uninstall of everything with rm by hand.

Trying to install the alpha/preview release using official installer works. Trying to install from pip directly also works. So it's seem related to the installer for 1.1.8 and some specific macOS thing, what do you guys think?

Thanks, and I hope I help someone with this issue, I didn't find anything related on my research.

ghost commented 3 years ago

And here's the list from pip3 list showing poetry installed (via official installer above):

Package                           Version
--------------------------------- ---------
backports.entry-points-selectable 1.1.0
CacheControl                      0.12.6
cachy                             0.3.0
certifi                           2021.5.30
charset-normalizer                2.0.4
cleo                              0.8.1
clikit                            0.6.2
crashtest                         0.3.1
distlib                           0.3.2
filelock                          3.0.12
html5lib                          1.1
idna                              3.2
keyring                           21.8.0
lockfile                          0.12.2
msgpack                           1.0.2
packaging                         20.9
pastel                            0.2.1
pexpect                           4.8.0
pip                               21.2.4
pkginfo                           1.7.1
platformdirs                      2.3.0
poetry                            1.1.8
poetry-core                       1.0.4
ptyprocess                        0.7.0
pylev                             1.4.0
pyparsing                         2.4.7
requests                          2.26.0
requests-toolbelt                 0.9.1
setuptools                        57.5.0
shellingham                       1.4.0
six                               1.16.0
tomlkit                           0.7.2
urllib3                           1.26.6
virtualenv                        20.7.2
webencodings                      0.5.1
wheel                             0.37.0
ghost commented 3 years ago

If I remove everything, start by upgrading pip, followed by installing poetry preview (which works), then uninstalling preview and installing 1.1.8, it seems to work. Why?! I have no clue.

Same thing happens if I try to install 1.1.8 (not working), and then try to overwrite the installation with 1.1.7 POETRY_VERSION=1.1.7 (works).

And the same if I try first 1.1.7 (not working), but then executing the installer again for 1.1.8 (works).

ghost commented 3 years ago

If I clean install 1.1.8, which will not work, and then try to reinstall by passing the --force attribute I get:

Traceback (most recent call last):
  File "<stdin>", line 554, in make_bin
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/pathlib.py", line 1374, in symlink_to
    self._accessor.symlink(target, self, target_is_directory)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/pathlib.py", line 442, in symlink
    return os.symlink(a, b)
FileExistsError: [Errno 17] File exists: '/Users/mateus/Library/Application Support/pypoetry/venv/bin/poetry' -> '/Users/mateus/Library/Python/3.8/bin/poetry'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 833, in <module>
  File "<stdin>", line 829, in main
  File "<stdin>", line 440, in run
  File "<stdin>", line 465, in install
  File "<stdin>", line 560, in make_bin
  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 261, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/mateus/Library/Application Support/pypoetry/venv/bin/poetry'

Which is weird, it's saying that poetry exists under /venv/bin but here's the directory listing:

$ ll /Users/mateus/Library/Application\ Support/pypoetry/venv/bin
total 104
-rw-r--r--  1 mateus  staff   2,1K  5 Set 17:30 activate
-rw-r--r--  1 mateus  staff   1,4K  5 Set 17:30 activate.csh
-rw-r--r--  1 mateus  staff   3,0K  5 Set 17:30 activate.fish
-rw-r--r--  1 mateus  staff   1,7K  5 Set 17:30 activate.ps1
-rw-r--r--  1 mateus  staff   1,2K  5 Set 17:30 activate_this.py
-rwxr-xr-x  1 mateus  staff   306B  5 Set 17:30 pip
-rwxr-xr-x  1 mateus  staff   306B  5 Set 17:30 pip-3.8
-rwxr-xr-x  1 mateus  staff   306B  5 Set 17:30 pip3
-rwxr-xr-x  1 mateus  staff   306B  5 Set 17:30 pip3.8
lrwxr-xr-x  1 mateus  staff   128B  5 Set 17:30 python -> /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python
lrwxr-xr-x  1 mateus  staff     6B  5 Set 17:30 python3 -> python
lrwxr-xr-x  1 mateus  staff     6B  5 Set 17:30 python3.8 -> python
-rwxr-xr-x  1 mateus  staff   293B  5 Set 17:30 wheel
-rwxr-xr-x  1 mateus  staff   293B  5 Set 17:30 wheel-3.8
-rwxr-xr-x  1 mateus  staff   293B  5 Set 17:30 wheel3
-rwxr-xr-x  1 mateus  staff   293B  5 Set 17:30 wheel3.8

And not to mention the FileNotFoundError followed by FileExistsError for the same path. I hope all this info makes sense to somebody.