theskumar / python-dotenv

Reads key-value pairs from a .env file and can set them as environment variables. It helps in developing applications following the 12-factor principles.
https://saurabh-kumar.com/python-dotenv/
BSD 3-Clause "New" or "Revised" License
7.7k stars 431 forks source link

cannot use pipx installed python-dotenv on Mac #501

Closed Youjin1985 closed 10 months ago

Youjin1985 commented 10 months ago

OS: Sohoma14.3 Situation: If I want to install python-dotenv globally with pipx, it does not work inside project poetry shell, giving me message "It seems python-dotenv is not installed with cli option". Meanwhile, if I pip install in poetry shell, it works, but this is not I want. (I don't want ot install dotenv in every project).

On Linux systems, including WSL, all works as expected - problem is on macOS.

To reproduce: on macOS, install pyenv global version 3.11.7, install pipx with 'pipx install dotenv' make poetry project and enter poetry shell try to use dotenv

theskumar commented 10 months ago

@Youjin1985 this is frequent issue, but i see you doing pipx install dotenv instead you should try pipx install python-dotenv

Hope that resolves your issue.

Youjin1985 commented 10 months ago

Unfortunately pipx install python-dotenv does not solve issue, same output with that.

theskumar commented 10 months ago

Alright. This would need some investigation. I'll try see if I can reproduce it as well.

bbc2 commented 10 months ago

I might be missing something but if you want the CLI, shouldn't you install it with pipx install python-dotenv[cli] (you may need to do pipx uninstall python-dotenv first)?

Youjin1985 commented 10 months ago

I might be missing something but if you want the CLI, shouldn't you install it with pipx install python-dotenv[cli] (you may need to do pipx uninstall python-dotenv first)?

Of course I tried this because there was message suggesting that, but there is no such package on Mac

zsh: no matches found: python-dotenv[cli]

theskumar commented 10 months ago

I could not reproduce on mac-os Sonoma 14.1.2

❯ pyenv
pyenv 2.3.35

❯ pipx --version
1.3.3

❯ poetry --version
Poetry (version 1.7.1)

Steps to reproduce:

❯ which dotenv
dotenv not found

❯ pipx install "python-dotenv[cli]"
  installed package python-dotenv 1.0.1, installed using Python 3.12.1
  These apps are now globally available
    - dotenv
done! ✨ 🌟 ✨

❯ pyenv global 3.11.7
❯ which dotenv
/Users/theskumar/.local/bin/dotenv
❯ poetry init
Configuration file exists at /Users/theskumar/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/theskumar/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.

This command will guide you through creating your pyproject.toml config.

Package name [poetry-test]:
Version [0.1.0]:
Description []:
Author [Saurabh Kumar <theskumar@users.noreply.github.com>, n to skip]:
License []:
Compatible Python versions [^3.11]:

Would you like to define your main dependencies interactively? (yes/no) [yes] no
Would you like to define your development dependencies interactively? (yes/no) [yes] no
Generated file

[tool.poetry]
name = "poetry-test"
version = "0.1.0"
description = ""
authors = ["Saurabh Kumar <theskumar@users.noreply.github.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Do you confirm generation? (yes/no) [yes]
❯ poetry shell
❯ which dotenv
/Users/theskumar/.local/bin/dotenv

❯ dotenv
Usage: dotenv [OPTIONS] COMMAND [ARGS]...

  This script is used to set, get or unset values from a .env file.

Options:
....
Youjin1985 commented 10 months ago

Ok, I found that I must escape brackets characters and only then it works. pipx install python-dotenv\[cli\] Thank you so much for help. Please keep this issue so anyone who meets this problem can see resolution there