python安装配置Theano ImportError:cannot import name 'configparser'
2017-04-25 20:48
936 查看
在安装配置python,安装mingw,安装theano时进行测试。在测试前,即所有环境配置完成后要重启电脑一次。测试时报出如下异常:ImportError:cannot import name 'configparser'
测试方式一:
将如下测试代码复制放到python中运行一下:
import numpy as np
import time
import theano
A = np.random.rand(1000,10000).astype(theano.config.floatX)
B = np.random.rand(10000,1000).astype(theano.config.floatX)
np_start = time.time()
AB = A.dot(B)
np_end = time.time()
X,Y = theano.tensor.matrices('XY')
mf = theano.function([X,Y],X.dot(Y))
t_start = time.time()
tAB = mf(A,B)
t_end = time.time()
print "NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)"%(np_end-np_start, t_end-t_start)
print "Result difference: %f"%(np.abs(AB-tAB).max(), )
测试方式二:
Import theano
print theano.config.blas.ldflags
通过上述两种方式进行测试,均未通过,报出如下异常:ImportError:cannot import name 'configparser'
解决方法:我修改了两个地方,然后重启电脑后,该异常信息消失。
修改处一:由于网上的教程,当时添加了一个环境变量,变量名称为:“PYTHONPATH”,变量值为“C:\Anaconda\Lib\site-packages\theano;”
的修改是将该环境变量删除,不用添加。
修改处二:修改.theanorc.txt文件。修改及部分说明如下图所示,为了方便复制,代码在最后面。
代码如下:
[global]
openmp=False
device = gpu
optimizer_including=cudnn
floatX = float32
allow_input_downcast=True
[lib]
cnmem = 0.8
[blas]
ldflags=
[gcc]
cxxflags=-IC:\Users\f\Anaconda3\MinGW
[nvcc]
flags = -LC:\Users\f\Anaconda3\libs
compiler_bindir = G:\VS\VC\bin
fastmath = True修改上述两处后,重启电脑,报出的异常信息就没有了。
测试方式一:
将如下测试代码复制放到python中运行一下:
import numpy as np
import time
import theano
A = np.random.rand(1000,10000).astype(theano.config.floatX)
B = np.random.rand(10000,1000).astype(theano.config.floatX)
np_start = time.time()
AB = A.dot(B)
np_end = time.time()
X,Y = theano.tensor.matrices('XY')
mf = theano.function([X,Y],X.dot(Y))
t_start = time.time()
tAB = mf(A,B)
t_end = time.time()
print "NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)"%(np_end-np_start, t_end-t_start)
print "Result difference: %f"%(np.abs(AB-tAB).max(), )
测试方式二:
Import theano
print theano.config.blas.ldflags
通过上述两种方式进行测试,均未通过,报出如下异常:ImportError:cannot import name 'configparser'
解决方法:我修改了两个地方,然后重启电脑后,该异常信息消失。
修改处一:由于网上的教程,当时添加了一个环境变量,变量名称为:“PYTHONPATH”,变量值为“C:\Anaconda\Lib\site-packages\theano;”
的修改是将该环境变量删除,不用添加。
修改处二:修改.theanorc.txt文件。修改及部分说明如下图所示,为了方便复制,代码在最后面。
代码如下:
[global]
openmp=False
device = gpu
optimizer_including=cudnn
floatX = float32
allow_input_downcast=True
[lib]
cnmem = 0.8
[blas]
ldflags=
[gcc]
cxxflags=-IC:\Users\f\Anaconda3\MinGW
[nvcc]
flags = -LC:\Users\f\Anaconda3\libs
compiler_bindir = G:\VS\VC\bin
fastmath = True修改上述两处后,重启电脑,报出的异常信息就没有了。
相关文章推荐
- 微软LightGBM Windows下Python安装:ImportError: cannot import name NUMPY_MKL
- Python: ImportError: cannot import name 'BeautifulSoup'
- Python模块Scrapy导入出错:ImportError: cannot import name xmlrpc_client
- python selectivesearch import Error:cannot import name 'selective_search'
- ubuntu 16.04 ros kinetic Moveit Python: ImportError: cannot import name structs
- Python: ImportError: cannot import name __check_buil
- 解决bs4在Python 3.5下出现“ImportError: cannot import name 'HTMLParseError'”错误
- Python Theano TypeError: Cannot convert Type TensorType(float64, vector) (of Variable Subtensor{int64:int64:}.0) into Type TensorType(float64, matrix)
- for the problem ImportError: cannot import name symbol_database 'text_format'
- 解决bs4在Python 3.6下出现“ImportError: cannot import name 'HTMLParseError'”错误
- Python——报错:ImportError: cannot import name requests
- Error creating bean with name 'XXX' in the [XXXX.xml] --The import XXX cannot be resolved
- Dagger 2 项目配置错误: error: the import javax.annotation.Generated cannot be resolved
- theano import error (win10 python2.7)
- 关于python "ImportError: cannot import name quotes_historical_yahoo" 问题
- 关于python "ImportError: cannot import name quotes_historical_yahoo" 问题
- Python ImportError: cannot import name *
- carbon报错 Python Error - ImportError: cannot import name daemonize
- python导入词云包失败:ImportError:cannot import name ‘WordCloud’的解决办法
- for the problem ImportError: cannot import name symbol_database 'text_format'