Can't use tkinter in virtual environment created by poetry
See original GitHub issue- OS version and name: Ubuntu 20.04
- Poetry version: 1.1.7
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/vitalije/77d16343bf8f0a99ec0946f2586edf5b
Issue
I have several python installations. Using one that I have compiled myself (*Python 3.9.6) with support of latest stable tk/tcl (8.6.11). This python when invoked directly has full support for tkinter library. However, when I create new virtual environment using:
poetry env use /path/to/my/python3.9.6
poetry shell
python -m tkinter
I get the error that python was not configured to use tkinter module.
When I manually add links lib/tcl8.6
and lib/tk8.6
to the virtual environment in ~/.cache/pypoetry/virtualenvs/mleo.../lib/
, python can use tkinter afterwards.
I was expecting that poetry would add those links when creating new virtual environment.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
ImportError: No module named 'Tkinter' - Stack Overflow
As you are using Python 3, the module has been renamed to tkinter ... in a virtualenv using for example python 3.7 was...
Read more >ModuleNotFoundError: No module named 'tkinter' in Python
The Python "ModuleNotFoundError: No module named 'tkinter'" occurs when tkinter is not installed in our Python environment. To solve the error, ...
Read more >Python - NixOS Wiki
Python 3.3-3.4 (old): the recommended way to create a virtual environment was to use the pyvenv command-line tool that also comes included with...
Read more >Installation - Streamlit Docs
Below are a few tools you can use for environment management: pipenv · poetry · venv · virtualenv · conda. Install Streamlit on...
Read more >pipenv · PyPI
You no longer need to use pip and virtualenv separately. They work together. · Managing a requirements. · Hashes are used everywhere, always....
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
I too have had this issue. After some testing, it seems fixed with the current version of Poetry. Try reinstalling it. Here are some fixes…
poetry env info -p
for the path to your virtualenvvirtualenv = 20.*.*
I hope this helped you. I know it is a bit late, but hopefully someone else stumbles upon this and it fixes their issue. 😄
My working version of pyvenv.cfg…
Ok, I tracked this down to poetry seemingly ignoring
poetry env use /path/to/python
in some cases. That is, you can have the following (pseudo-bash):Perhaps you have to
poetry env use /path/to/python
before even creating the environment? If so, it’s incredibly misleading thatpoetry env use
is a no-op once the environment has been created.