Discussion:
anaconda bug?
(too old to reply)
George Trojan
2015-03-16 23:14:44 UTC
Permalink
I am not sure it is just me or there is a bug in anaconda. I installed
miniconda from http://conda.pydata.org/miniconda.html, then several
python3.4.3 packages. Then created virtual environment. When I switch to
that environment I can not create tk root window. Here is the traceback:

(venv-3.4.3) $ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Mar 6 2015, 12:03:53)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import tkinter
tkinter.Tk()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gtrojan/miniconda3/lib/python3.4/tkinter/__init__.py",
line 1851, in __init__
self.tk = _tkinter.create(screenName, baseName, className,
interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following
directories:
/opt/anaconda1anaconda2anaconda3/lib/tcl8.5
/home/gtrojan/venv-3.4.3/lib/tcl8.5 /home/gtrojan/lib/tcl8.5
/home/gtrojan/venv-3.4.3/library /home/gtrojan/library
/home/gtrojan/tcl8.5.18/library /home/tcl8.5.18/library

It looks like the search path for tcl/tk libraries is messed up. The
same command works fine when I exit virtual environment though. I do not
have a problem with python 3.4.2 built from source on the same system.

For a workaround, I set TCL_LIBRARY and TK_LIBRARY in activate:

# bug in anaconda?
_OLD_TCL_LIBRARY="$TCL_LIBRARY"
TCL_LIBRARY="/home/gtrojan/miniconda3/lib/tcl8.5"
export TCL_LIBRARY
_OLD_TK_LIBRARY="$TK_LIBRARY"
TK_LIBRARY="/home/gtrojan/miniconda3/lib/tk8.5"
export TK_LIBRARY

I have found somewhat similar bug report:
https://github.com/conda/conda/issues/348.

George
memilanuk
2015-03-16 23:47:22 UTC
Permalink
Might be just you...

***@machin-shin:~$ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Mar 6 2015, 12:03:53)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import tkinter
tkinter.Tk()
<tkinter.Tk object at 0x7ff4c6fc8160>
Just for the heck of it I created a new venv (using conda create -n
test) and tried it again. Same thing.

How are you creating your venv?

Monte
--
Shiny! Let's be bad guys.

Reach me @ memilanuk (at) gmail dot com
George Trojan
2015-03-17 16:51:03 UTC
Permalink
Post by memilanuk
Might be just you...
Python 3.4.3 |Continuum Analytics, Inc.| (default, Mar 6 2015, 12:03:53)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import tkinter
tkinter.Tk()
<tkinter.Tk object at 0x7ff4c6fc8160>
Just for the heck of it I created a new venv (using conda create -n
test) and tried it again. Same thing.
How are you creating your venv?
Monte
Hmm. I tried on the different system (Fedora 20), with Python 3.4.2.
Same results:

***@gtrojan> python
Python 3.4.2 |Continuum Analytics, Inc.| (default, Oct 21 2014, 17:16:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Post by memilanuk
import tkinter
tkinter.Tk()
<tkinter.Tk object at 0x7f5713951630>
***@gtrojan> which pyvenv
/usr/local/miniconda3/bin/pyvenv
***@gtrojan> pyvenv --system-site-packages ~/test
***@gtrojan> source ~/test/bin/activate
(test) ***@gtrojan> python
Python 3.4.2 |Continuum Analytics, Inc.| (default, Oct 21 2014, 17:16:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Post by memilanuk
import tkinter
tkinter.Tk()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/miniconda3/lib/python3.4/tkinter/__init__.py", line
1851, in __init__
self.tk = _tkinter.create(screenName, baseName, className,
interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following
directories:
/opt/anaconda1anaconda2anaconda3/lib/tcl8.5
/home/gtrojan/test/lib/tcl8.5 /home/gtrojan/lib/tcl8.5
/home/gtrojan/test/library /home/gtrojan/library
/home/gtrojan/tcl8.5.15/library /home/tcl8.5.15/library

This probably means that Tcl wasn't installed properly.
I suspect faulty logic: pyvenv does not copy/links the tcl/tk libraries
to the newly created directory. When I run python directly, the second
directory to search is /usr/local/miniconda3/lib/tcl8.5, where conda
puts its tcl version. In virtual environment, the path is replaced and
tkinter fails. So the other fix would be to manually create symlinks
after running pyvenv, or modify Continuum Analytics pyvenv to do that.
There is no issue with pyvenv when Python is built from the source, the
first directory in the path is where tcl is found by configure and that
does not change in virtual environment.

I found another similar bug report here:
https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/Q9xvJT8khTs
Looks this has not been fixed.

George
memilanuk
2015-03-17 17:25:11 UTC
Permalink
Post by George Trojan
Post by memilanuk
Might be just you...
Python 3.4.3 |Continuum Analytics, Inc.| (default, Mar 6 2015, 12:03:53)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import tkinter
tkinter.Tk()
<tkinter.Tk object at 0x7ff4c6fc8160>
Just for the heck of it I created a new venv (using conda create -n
test) and tried it again. Same thing.
How are you creating your venv?
Monte
Hmm. I tried on the different system (Fedora 20), with Python 3.4.2.
Python 3.4.2 |Continuum Analytics, Inc.| (default, Oct 21 2014, 17:16:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Post by memilanuk
import tkinter
tkinter.Tk()
<tkinter.Tk object at 0x7f5713951630>
/usr/local/miniconda3/bin/pyvenv
Python 3.4.2 |Continuum Analytics, Inc.| (default, Oct 21 2014, 17:16:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Post by memilanuk
import tkinter
tkinter.Tk()
File "<stdin>", line 1, in <module>
File "/usr/local/miniconda3/lib/python3.4/tkinter/__init__.py", line
1851, in __init__
self.tk = _tkinter.create(screenName, baseName, className,
interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following
/opt/anaconda1anaconda2anaconda3/lib/tcl8.5
/home/gtrojan/test/lib/tcl8.5 /home/gtrojan/lib/tcl8.5
/home/gtrojan/test/library /home/gtrojan/library
/home/gtrojan/tcl8.5.15/library /home/tcl8.5.15/library
This probably means that Tcl wasn't installed properly.
I suspect faulty logic: pyvenv does not copy/links the tcl/tk libraries
to the newly created directory. When I run python directly, the second
directory to search is /usr/local/miniconda3/lib/tcl8.5, where conda
puts its tcl version. In virtual environment, the path is replaced and
tkinter fails. So the other fix would be to manually create symlinks
after running pyvenv, or modify Continuum Analytics pyvenv to do that.
There is no issue with pyvenv when Python is built from the source, the
first directory in the path is where tcl is found by configure and that
does not change in virtual environment.
https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/Q9xvJT8khTs
Looks this has not been fixed.
Well, it might be worth poking them and seeing if you get any response.

What happens if you create a venv using conda? Is there some particular
reason you're using Anaconda but not using its tools for managing
virtualenvs? I get it that pyenv should work, but it might be useful to
isolate it further to tell if its just pyenv, or something else. I
don't have any experience with pyenv myself, sorry.

HTH,

Monte
--
Shiny! Let's be bad guys.

Reach me @ memilanuk (at) gmail dot com
Loading...