Skip to content

poetry env activate does not work on windows when python is not in environment #10024

@teddy661

Description

@teddy661

Description

Upgraded to poetry 2.0.1 attempted to launch a shell using poetry env activate and receive the following error message for powershell and cmd:

Python installation options are: for all users; Do not add Python to environment variables ;

the command poetry shell worked correctly for this configuration

PWSH
PS C:\Users\xxx.xxx\Desktop\automation_python> poetry env activate
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
& "C:\Users\xxx.xxx\Desktop\automation_python.venv\Scripts\Activate.ps1"
PS C:\Users\xxx.xxx\Desktop\automation_python>

CMD
C:\Users\xxx.xxx\Desktop\automation_python>poetry env activate
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
"C:\Users\xxx.xxx\Desktop\automation_python.venv\Scripts\activate.bat"

C:\Users\xxx.xxx\Desktop\tautomation_python>

Workarounds

Calling the scripts directly from the shell works.

CMD
C:\Users\xxx.xxx\Desktop\automation_python>"C:\Users\xxx.xxx\Desktop\automation_python.venv\Scripts\activate.bat"

(tautomation-python-py3.13) C:\Users\xxx.xxx\Desktop\automation_python>

PWSH
PS C:\Users\xxx.xxx\Desktop\automation_python> & "C:\Users\xxx.xxx\Desktop\tc_dev_automation_python.venv\Scripts\Activate.ps1"
(automation-python-py3.13) PS C:\Users\xxx.xxx\Desktop\automation_python>

Poetry Installation Method

install.python-poetry.org

Operating System

Windows 11 10.0.26100

Poetry Version

Poetry (version 2.0.1)

Poetry Configuration

cache-dir = "C:\\Users\\xxx.xxx\\AppData\\Local\\pypoetry\\Cache"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\xxx.xxx\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

sysconfig.log
Paths:
      data = "C:\python\Python313"
      include = "C:\python\Python313\Include"
      platinclude = "C:\python\Python313\Include"
      platlib = "C:\python\Python313\Lib\site-packages"
      platstdlib = "C:\python\Python313\Lib"
      purelib = "C:\python\Python313\Lib\site-packages"
      scripts = "C:\python\Python313\Scripts"
      stdlib = "C:\python\Python313\Lib"

Variables:
      BINDIR = "C:\Python\Python313"
      BINLIBDEST = "C:\python\Python313\Lib"
      EXE = ".exe"
      EXT_SUFFIX = ".cp313-win_amd64.pyd"
      INCLUDEPY = "C:\python\Python313\Include"
      LDLIBRARY = "python313.dll"
      LIBDEST = "C:\python\Python313\Lib"
      LIBDIR = "C:\Python\Python313\libs"
      LIBRARY = "python313.dll"
      Py_GIL_DISABLED = "0"
      SOABI = "cp313-win_amd64"
      TZPATH = ""
      VERSION = "313"
      VPATH = "..\.."
      abi_thread = ""
      abiflags = ""
      base = "C:\python\Python313"
      exec_prefix = "C:\python\Python313"
      implementation = "Python"
      implementation_lower = "python"
      installed_base = "C:\python\Python313"
      installed_platbase = "C:\python\Python313"
      platbase = "C:\python\Python313"
      platlibdir = "DLLs"
      prefix = "C:\python\Python313"
      projectbase = "C:\Python\Python313"
      py_version = "3.13.1"
      py_version_nodot = "313"
      py_version_nodot_plat = "313"
      py_version_short = "3.13"
      srcdir = "C:\Python\Python313"
      userbase = "C:\Users\xxx.xxx\AppData\Roaming\Python"

Example pyproject.toml

[tool.poetry]
name = "automation_python"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.13"
beautifulsoup4 = "^4.12.3"
lxml = "^5.3.0"
validators = "^0.34.0"
jproperties = "^2.1.2"
pywin32 = "^308"
psutil = "^6.1.1"


[tool.poetry.group.dev.dependencies]
ipython = "^8.31.0"
black = "^24.10.0"
pickleshare = "^0.7.5"
isort = "^5.13.2"

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

Poetry Runtime Logs

poetry-runtime.log
Loading configuration file C:\Users\xxx.xxx\AppData\Roaming\pypoetry\config.toml
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
& "C:\Users\xxx.xxx\Desktop\automation_python\.venv\Scripts\Activate.ps1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expectedstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions