Monday, July 11, 2022

[SOLVED] python poetry how to install for all users ubuntu 18.04?

Issue

I am trying to install poetry for all users on ubuntu 18.04 and it doesn't seem to work.

I have tried the script (which installs to a local user's home directory)

class="lang-bash prettyprint-override">
$ curl -sSL https://install.python-poetry.org | python3 -
# this works but is only installed for the current user

and I've tried pip:


$ pip install poetry
$ poetry
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

I also tried manually moving the poetry binary into /usr/local/bin but there are library dependencies that are not available.


Solution

this is how I solved it:


# copy poetry bin and lib to /usr/local/bin and /usr/local/lib
$ cd ~/.local/lib/python3.8/site-packages
$ sudo cp -R ./poetry-1.1.13.dist-info/ /usr/local/lib/python3.8/dist-packages/
$ sudo cp -R ./poetry_core-1.0.8.dist-info/ /usr/local/lib/python3.8/dist-packages/
$ sudo cp -a . /usr/local/lib/python3.8/dist-packages/
$ cd ~/.local/bin
$ sudo cp poetry /usr/local/bin/
$ sudo chmod -R 775 /usr/local/lib/python3.8/dist-packages/



Answered By - fjlksahfob
Answer Checked By - Mary Flores (WPSolving Volunteer)