1.2.0 fails to recognise external active virtualenv
See original GitHub issue- Poetry version: 1.2.0
- Python version: 3.8.x
- OS version and name: ubuntu 22.04 and macOS 12.5
- pyproject.toml: any
- I am on the latest stable Poetry version, installed using a recommended method.
- I have searched the issues of this repo and believe that this is not a duplicate.
- I have consulted the FAQ and blog for any relevant entries or release notes.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption) and have included the output below.
Issue
External envs are not correctly detected by poetry 1.2.0
to reproduce (with default poetry config)
rm -rf /tmp/venv/ && python3 -m venv /tmp/venv && . /tmp/venv/bin/activate && poetry install -v
shows: Creating virtualenv ${poetry_project_name}-Wz7GVy6b-py3.8 in /Users/myuser/Library/Caches/pypoetry/virtualenvs
when
poetry config virtualenvs.create false is set
the above command produces:
Skipping virtualenv creation, as specified in config file.
Installing dependencies from lock file
Finding the necessary packages for the current system
Package operations: 286 installs, 16 updates, 0 removals
• Updating six (1.15.0 /AppleInternal/Library/BuildRoots/a0876c02-1788-11ed-b9c4-96898e02b808/Library/Caches/com.apple.xbs/Sources/python3_modules/six-1.15.0-py2.py3-none-any.whl -> 1.16.0): Failed
CalledProcessError
Command '['/AppleInternal/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8', '/Users/myuser/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/virtualenv/seed/wheels/embed/pip-22.2.2-py3-none-any.whl/pip', 'install', '--disable-pip-version-check', '--prefix', '/AppleInternal/Library/Frameworks/Python.framework/Versions/3.8', '--upgrade', '--no-deps', '/Users/myuser/Library/Caches/pypoetry/artifacts/e8/bc/c6/8f0343a6a2046d1f17d0a28efec62de264c2eab04ebcb6b3a74d62a9f8/six-1.16.0-py2.py3-none-any.whl']' returned non-zero exit status 1.
as one can see poetry is trying to install to the system instead of the activated venv and fails (as expected) due to permissions
poetry env info doesn’t show paths to the activated external venv:
➜ poetry env info
Virtualenv
Python: 3.8.9
Implementation: CPython
Path: NA
Executable: NA
System
Platform: darwin
OS: posix
Python: 3.8.9
Path: /AppleInternal/Library/Frameworks/Python.framework/Versions/3.8
Executable: /AppleInternal/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
[SOLVED] Getting "Failed to activate virtualenv" when using ...
I tried update pyenv but I'm getting an error when trying to use pyenv-virtualenv: Failed to activate virtualenv. Perhaps pyenv-virtualenv ...
Read more >Unable to activate virtual environment in Python - Stack Overflow
Using python 3.10.2 and virtualenv 16.7.5 gives me the same error. Looks like virtualenv 16.7.5 is too old for 3.10.2.
Read more >is not recognized as an internal or external command - Windows
In this tutorial, I would like to show you the python problem solution that “' virtualenv ' is not recognized as an internal...
Read more >virtualenvwrapper-win - PyPI
If a virtualenv environment is active and a projectdir has been defined, change the current working directory to active virtualenv's project directory. cd- ......
Read more >Working with Python virtual environments: the complete guide
Working with dependencies is a fact of life. With this post, learn about dependency management in Python using virtual environments!
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Its worth nothing that everything works for me as expected on macOS as well. I’m going to close this for now as neither of us can reproduce it reliably – I suggest you inspect the shell environment after
activateto make sureVIRTUAL_ENVandPATHare set correctly (local configuration is likely what is at fault for you here).Our virtual environment detection mechanism is a bit complex as we do have a class-based
Envthat’s used to do handling of different types of environment – that being said, I’m not 100% sure what you mean.