Can't install poetry using pip on a blank Repl

I’m not sure if this is only limited to a Blank Repl, but installing poetry through pip does not work due to the ridiculous amount of perms limitations, resulting in an OSError when using the -U parameter.

Edit: This is only limited to a Blank Repl, so I’m guessing the Python template was created before changes were made to root perms and such.

4 Likes

I don’t really see how this would be related to permissions, but it is likely to give errors on a blank repl because it is not specially configured with venv and whatnot unlike a python repl.

3 Likes

That’s a good point, and it’s what your tutorial suggests anyway.


Anyway, I tested the command again, and received the following error:

ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/nix/store/h4h5rxs0hzpzvz37yrwv1k2na1acgzww-python3-3.9.15/lib/python3.9/site-packages/webencodings'
Consider using the `--user` option or check the permissions.

--- Logging error ---
Traceback (most recent call last):
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 177, in emit
    self.console.print(renderable, overflow="ignore", crop=False, style=style)
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_vendor/rich/console.py", line 1673, in print
    extend(render(renderable, render_options))
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_vendor/rich/console.py", line 1305, in render
    for render_output in iter_render:
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 134, in __rich_console__
    for line in lines:
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_vendor/rich/segment.py", line 249, in split_lines
    for segment in segments:
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_vendor/rich/console.py", line 1283, in render
    renderable = rich_cast(renderable)
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_vendor/rich/protocol.py", line 36, in rich_cast
    renderable = cast_method()
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/self_outdated_check.py", line 130, in __rich__
    pip_cmd = get_best_invocation_for_this_pip()
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/utils/entrypoints.py", line 58, in get_best_invocation_for_this_pip
    if found_executable and os.path.samefile(
  File "/nix/store/h4h5rxs0hzpzvz37yrwv1k2na1acgzww-python3-3.9.15/lib/python3.9/genericpath.py", line 101, in samefile
    s2 = os.stat(f2)
FileNotFoundError: [Errno 2] No such file or directory: '/nix/store/h4h5rxs0hzpzvz37yrwv1k2na1acgzww-python3-3.9.15/bin/pip'
Call stack:
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/bin/.pip-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 70, in main
    return command.main(cmd_args)
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 101, in main
    return self._main(args)
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
    self.handle_pip_version_check(options)
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 190, in handle_pip_version_check
    pip_self_version_check(session, options)
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/self_outdated_check.py", line 236, in pip_self_version_check
    logger.warning("[present-rich] %s", upgrade_prompt)
  File "/nix/store/h4h5rxs0hzpzvz37yrwv1k2na1acgzww-python3-3.9.15/lib/python3.9/logging/__init__.py", line 1458, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "/nix/store/h4h5rxs0hzpzvz37yrwv1k2na1acgzww-python3-3.9.15/lib/python3.9/logging/__init__.py", line 1589, in _log
    self.handle(record)
  File "/nix/store/h4h5rxs0hzpzvz37yrwv1k2na1acgzww-python3-3.9.15/lib/python3.9/logging/__init__.py", line 1599, in handle
    self.callHandlers(record)
  File "/nix/store/h4h5rxs0hzpzvz37yrwv1k2na1acgzww-python3-3.9.15/lib/python3.9/logging/__init__.py", line 1661, in callHandlers
    hdlr.handle(record)
  File "/nix/store/h4h5rxs0hzpzvz37yrwv1k2na1acgzww-python3-3.9.15/lib/python3.9/logging/__init__.py", line 952, in handle
    self.emit(record)
  File "/nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 179, in emit
    self.handleError(record)
Message: '[present-rich] %s'
Arguments: (UpgradePrompt(old='22.2.2', new='23.1.2'),)

It does also suggest using the --user parameter, so it seems it may have to do with perms.

Regardless though, it doesn’t have an effect on your tutorial but thought it would be worth mentioning.

2 Likes

Create and activate a venv, then try that.

2 Likes

Actually, never mind. I just noticed that even after installing python and pip, the venv folder isn’t present, and it just defaults to erroring out suggesting it has something to do with permissions instead.

Edit: whoops I didn’t see @9pfs1 response :laughing:

3 Likes

Try this:

python3 -m venv venv/
mkdir -p .config
echo source venv/bin/activate > .config/bashrc
exit
3 Likes

Works great! Thank you for the help. For anyone who is interested in setting this up from a clean, blank Repl, here is the full guide.


Firstly, create a new Blank Repl, and remove the cowsay package from replit.nix.

Secondly, execute the pip command, and install the most recent version. This should install the corresponding Python version as well.

Next, run all the commands as @9pfs1 suggests above. This should successfully create a venv and allow for dependencies to be used.

Almost there. Install poetry by executing pip install poetry -U. Then, after installing, invoke poetry init to create a pyproject.toml. Once complete, invoke poetry lock and you should be good to go! Add more dependencies as needed with poetry add [dep].


Thanks again for @9pfs1’s and @dragonhunter1’s replies!

3 Likes

Because this process is extremely time-consuming, I am working on creating a template. I have encountered an issue when attempting to upgrade pip (this is after creating a venv, and successfully installing poetry), resulting in the following when invoking pip install --upgrade pip.

Requirement already satisfied: pip in /nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages (22.2.2)
Collecting pip
  Using cached pip-23.1.2-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.2.2
    Not uninstalling pip at /nix/store/95kl4499yaa91j0ja7vwzf5l7r3ly4b2-python3.9-pip-22.2.2/lib/python3.9/site-packages, outside environment /home/runner/Python-with-Poetry/venv
    Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-23.1.2

[notice] A new release of pip available: 22.2.2 -> 23.1.2
[notice] To update, run: pip install --upgrade pip

What’s odd is it says it has successfully installed the new version of pip, but than informs us there is a new version available once again. I know the template is about poetry, but it would still be ideal to have the most updated version of pip. Is this problem fixable?

3 Likes

You can’t update it afaik (and shouldn’t need to).

3 Likes

Oh well, probably a Nix thing I’m assuming. Thank you!

2 Likes

The venv probably is later in $PATH than the nix package or something.

2 Likes

Ok, I believe my template should be complete now!

https://replit.com/@bobastley/Python-with-Poetry?v=1

The template is not completely setup, and it is highly recommended you read IMPORTANT.md.

If you have any suggestions, let me know!

Edit: It appears there are currently some issues with poetry not being installed after forking. I’m going to see if I am able to fix this.

3 Likes

@bobastley why not just use a Python template?

4 Likes

Well, I feel like it is a huge hassle to correctly configure every Python Repl I make with poetry, and I prefer having the flexibility of a Blank Repl. That is just my opinion though, it is completely up to you if you choose to use the template or not. (It doesn’t even seem to be working right now, which is extremely odd because I installed everything)

4 Likes

I’m extremely confused. My template is updated to the latest version, and I’m sure everything is installed correctly. However, after forking/using the template from the cover page, poetry isn’t installed, and everything acts like a venv doesn’t even exist! Does anyone have any ideas, or would be willing to collaborate?

2 Likes

I WANNA COLLAB

So,
Flexibility: Blank Repl > Python Template (I agree on that. Once, I deleted pyproject.toml and it deleted every package then created pyproject.toml again)
And, you wanna make a more flexibile python template that has poetry configured correctly

1 Like

I’ve invited you. Do you have any idea why this might be happening? I’m not even sure if Replit even copies over dependencies or if they have to be reinstalled upon forking, but it still doesn’t explain why venv doesn’t seem to be working anymore.

What are those?

Maybe it’s because of your editions. Or maybe Replit changed how venv gets created in Repls.
What is venv anyway?

1 Like

Could you add me to it?

1 Like

Just added you now. The issue is with the forked Repls, not the template itself.

1 Like