Install Theano on Windows for Python 3

1,246 views
Skip to first unread message

Ziyuan Lin

unread,
Dec 2, 2013, 1:29:34 PM12/2/13
to theano...@googlegroups.com
Hi all,

I have git and 2to3 in my Windows system and I am sure the OS can find them. I used pip isntall git+git://github.com/Theano/Theano.git to install, but I ended up with the following messages. Any ideas? THank you.

Best,
Ziyuan

--------------------

In cmd:

>python
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\theano\gof\lazylinker_c.py", line 58, in <module>
    raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\theano\gof\lazylinker_c.py", line 75, in <module>
    raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python33\lib\site-packages\theano\__init__.py", line 55, in <module>
    from theano.compile import \
  File "C:\Python33\lib\site-packages\theano\compile\__init__.py", line 6, in <module>
    from theano.compile.function_module import *
  File "C:\Python33\lib\site-packages\theano\compile\function_module.py", line 18, in <module>
    import theano.compile.mode
  File "C:\Python33\lib\site-packages\theano\compile\mode.py", line 11, in <module>
    import theano.gof.vm
  File "C:\Python33\lib\site-packages\theano\gof\vm.py", line 516, in <module>
    from . import lazylinker_c
  File "C:\Python33\lib\site-packages\theano\gof\lazylinker_c.py", line 84, in <module>
    args = cmodule.GCC_compiler.compile_args()
  File "C:\Python33\lib\site-packages\theano\gof\cmodule.py", line 1594, in compile_args
    native_lines = get_lines("g++ -march=native -E -v -")
  File "C:\Python33\lib\site-packages\theano\gof\cmodule.py", line 1568, in get_lines
    (stdout, stderr) = p.communicate(input='')
  File "C:\Python33\lib\subprocess.py", line 928, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "C:\Python33\lib\subprocess.py", line 1202, in _communicate
    self.stdin.write(input)
TypeError: 'str' does not support the buffer interface
>>>


In IPython:

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
%guiref   -> A brief reference about the graphical user interface.

In [1]: import theano
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-3397704bd624> in <module>()
----> 1 import theano

C:\Python33\lib\site-packages\theano\__init__.py in <module>()
     53     object2, utils
     54 
---> 55 from theano.compile import      56     SymbolicInput, In,      57     SymbolicOutput, Out, 
C:\Python33\lib\site-packages\theano\compile\__init__.py in <module>()
      4         ViewOp, view_op, register_view_op_c_code)
      5 
----> 6 from theano.compile.function_module import *
      7 
      8 from theano.compile.mode import *

C:\Python33\lib\site-packages\theano\compile\function_module.py in <module>()
     16 from theano import gof
     17 from theano.gof.python25 import partial
---> 18 import theano.compile.mode
     19 from theano.compile.io import In, SymbolicInput, SymbolicInputKit, SymbolicOutput
     20 from theano.compile.ops import deep_copy_op, view_op

C:\Python33\lib\site-packages\theano\compile\mode.py in <module>()
      9 import  theano
     10 from theano import gof
---> 11 import theano.gof.vm
     12 from theano.configparser import config, AddConfigVar, StrParam
     13 from theano.compile.ops import register_view_op_c_code, _output_guard

C:\Python33\lib\site-packages\theano\gof\vm.py in <module>()
    514 
    515 try:
--> 516     from . import lazylinker_c
    517 
    518     class CVM(lazylinker_c.CLazyLinker, VM):

C:\Python33\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
     82             if not os.path.exists(loc):
     83                 os.mkdir(loc)
---> 84             args = cmodule.GCC_compiler.compile_args()
     85             cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
     86                                              preargs=args)

C:\Python33\lib\site-packages\theano\gof\cmodule.py in compile_args()
   1592             # The '-' at the end is needed. Otherwise, g++ do not output
   1593             # enough information.
-> 1594             native_lines = get_lines("g++ -march=native -E -v -")
   1595             if native_lines is None:
   1596                 _logger.info("Call to 'g++ -march=native' failed,"

C:\Python33\lib\site-packages\theano\gof\cmodule.py in get_lines(cmd, parse)
   1566                 # waiting forever without returning. For that reason,
   1567                 # we use a pipe, and use the empty string as input.
-> 1568                 (stdout, stderr) = p.communicate(input='')
   1569                 if p.returncode != 0:
   1570                     return None

C:\Python33\lib\subprocess.py in communicate(self, input, timeout)
    926 
    927             try:
--> 928                 stdout, stderr = self._communicate(input, endtime, timeout)
    929             finally:
    930                 self._communication_started = True

C:\Python33\lib\subprocess.py in _communicate(self, input, endtime, orig_timeout)
   1200                 if input is not None:
   1201                     try:
-> 1202                         self.stdin.write(input)
   1203                     except IOError as e:
   1204                         if e.errno != errno.EPIPE:

TypeError: 'str' does not support the buffer interface

In [2]:

Frédéric Bastien

unread,
Dec 2, 2013, 3:14:45 PM12/2/13
to theano...@googlegroups.com
Can you change line 1568 form this filee:

C:\Python33\lib\site-packages\theano\gof\cmodule.py

from:
(stdout, stderr) = p.communicate(input='')

to:

(stdout, stderr) = p.communicate(input=theano.compat.u(''))

if it don't work, you can try this one:

(stdout, stderr) = p.communicate(input=theano.compat.b(''))

Tell us if it fix your problem.

thanks

Fred
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "theano-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to theano-users...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Ziyuan Lin

unread,
Dec 2, 2013, 4:04:51 PM12/2/13
to theano...@googlegroups.com, no...@nouiz.org
This only solves the issue at import. When running theano.test(), the errors still appear. For example:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\theano\gof\opt.py", line 1285, in process_node
    replacements = lopt.transform(node)
  File "C:\Python33\lib\site-packages\theano\gof\opt.py", line 819, in transform
    repl = opt.transform(node)
  File "C:\Python33\lib\site-packages\theano\tensor\blas_c.py", line 261, in use_c_ger
    if not config.blas.ldflags:
  File "C:\Python33\lib\site-packages\theano\configparser.py", line 273, in __get__
    val_str = self.default()
  File "C:\Python33\lib\site-packages\theano\tensor\blas.py", line 282, in default_blas_ldflags
    if GCC_compiler.try_flags(["-lblas"]):
  File "C:\Python33\lib\site-packages\theano\gof\cmodule.py", line 1843, in try_flags
    flags=flag_list, try_run=False)
  File "C:\Python33\lib\site-packages\theano\gof\cmodule.py", line 1790, in try_compile_tmp
    os.write(fd, src_code)
TypeError: 'str' does not support the buffer interface

Also, theano.test() complains about No section: 'blas' and KeyError: 'blas.ldflags':

Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\theano\configparser.py", line 118, in fetch_val_for_key
    return theano_cfg.get(section, option)
  File "C:\Python33\lib\configparser.py", line 771, in get
    d = self._unify_values(section, vars)
  File "C:\Python33\lib\configparser.py", line 1136, in _unify_values
    raise NoSectionError(section)
configparser.NoSectionError: No section: 'blas'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\theano\configparser.py", line 270, in __get__
    val_str = fetch_val_for_key(self.fullname)
  File "C:\Python33\lib\site-packages\theano\configparser.py", line 122, in fetch_val_for_key
    raise KeyError(key)
KeyError: 'blas.ldflags'

I've put libblas.dllliblapack.dll, and liblapacke.dll (downloaded from here) into Windows\System32\ , but it doesn't work. Are there anything I can do? Thanks.

Best,
Ziyuan

Frédéric Bastien

unread,
Dec 2, 2013, 4:11:32 PM12/2/13
to theano...@googlegroups.com
There seam a problem happened during the installation. Normally, it
should work. It seam some of 2to3 fixer wasn't applied.

How did you install Theano? The command line if possible?

Can you try to uninstall it and reinstall it? Did you stopped the
installation? Did it crashed or gave errors?

Fred

Ziyuan Lin

unread,
Dec 2, 2013, 4:44:29 PM12/2/13
to theano...@googlegroups.com, no...@nouiz.org
It seems the buffer fixer has been skipped:

>pip install git+git://github.com/Theano/Theano.git
Downloading/unpacking git+git://github.com/Theano/Theano.git
  Cloning git://github.com/Theano/Theano.git to c:\users\ziyuan\appdata\local\temp\pip-vy7fbh-build
  Running setup.py egg_info for package from git+git://github.com/Theano/Theano.git

    warning: manifest_maker: MANIFEST.in, line 7: 'recursive-include' expects <dir> <pattern1> <pattern2> ...

Requirement already satisfied (use --upgrade to upgrade): numpy>=1.5.0 in c:\python33\lib\site-packages (from Theano==0.6.0rc5)
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.7.2 in c:\python33\lib\site-packages (from Theano==0.6.0rc5)
Installing collected packages: Theano
  Running setup.py install for Theano
    Skipping implicit fixer: buffer
    Skipping implicit fixer: idioms
    Skipping implicit fixer: set_literal
    Skipping implicit fixer: ws_comma
    Skipping implicit fixer: buffer
    Skipping implicit fixer: idioms
    Skipping implicit fixer: set_literal
    Skipping implicit fixer: ws_comma

    warning: manifest_maker: MANIFEST.in, line 7: 'recursive-include' expects <dir> <pattern1> <pattern2> ...

Successfully installed Theano
Cleaning up...

Best,
Ziyuan

Ziyuan Lin

unread,
Dec 2, 2013, 4:54:12 PM12/2/13
to theano...@googlegroups.com, no...@nouiz.org
OK, actually after uninstalling, reinstalling, and creating a ~/.theanorc.txt with sections [global] and [blas], it seems to be working. Thanks for you patience.

Best,
Ziyuan

nanaya tachibana

unread,
Dec 10, 2013, 9:47:54 AM12/10/13
to theano...@googlegroups.com, no...@nouiz.org
Hi, I have the same problem when I install theano on windows 7. I get same  output as you after installing. I have tried reinstalling, but get the same result. Could you tell me more detail about how you fix it? Why and where should .theanorc.txt be created?

Thanks. 

Pascal Lamblin

unread,
Dec 10, 2013, 4:31:33 PM12/10/13
to theano...@googlegroups.com
On Tue, Dec 10, 2013, nanaya tachibana wrote:
> Hi, I have the same problem when I install theano on windows 7. I get same
> output as you after installing. I have tried reinstalling, but get the
> same result. Could you tell me more detail about how you fix it?

So, I had a look in a virtualenv with python 3, and
added some changes in the following pull request:
https://github.com/Theano/Theano/pull/1660

> Why and where should .theanorc.txt be created?

This is a configuration file that lets you specify values for some
configuration variables. In this particular case, providing a section
for blas.ldflags (see below) will bypass the automatic detection of the
BLAS flags, which is where one of the errors is triggered.

[blas]
ldflags = ...
Pascal

Pascal Lamblin

unread,
Dec 11, 2013, 4:14:59 PM12/11/13
to theano...@googlegroups.com
On Tue, Dec 10, 2013, Pascal Lamblin wrote:
> On Tue, Dec 10, 2013, nanaya tachibana wrote:
> > Hi, I have the same problem when I install theano on windows 7. I get same
> > output as you after installing. I have tried reinstalling, but get the
> > same result. Could you tell me more detail about how you fix it?
>
> So, I had a look in a virtualenv with python 3, and
> added some changes in the following pull request:
> https://github.com/Theano/Theano/pull/1660

The pull request has been merged.
If you upgrade to the development version of Theano [1], this problem should be solved.

[1] http://deeplearning.net/software/theano/install.html#bleeding-edge-install-instructions

--
Pascal
Reply all
Reply to author
Forward
Message has been deleted
0 new messages