首页 \ 问答 \ 使用Windows子系统Linux时设置Matplotlib后端(Set Matplotlib backend when using Windows Subsystem for Linux)

使用Windows子系统Linux时设置Matplotlib后端(Set Matplotlib backend when using Windows Subsystem for Linux)

我的Matplotlib后端一直在恢复TkAgg 。 这是一个问题,因为在Windows子系统Linux(WSL)中,你不能做GUI的东西,所以我得到错误

TclError:没有显示名称和没有$ DISPLAY环境变量

我已经尝试将matplotlibrc文件添加到C:\Users\<user>\AppData\Local\lxss\home\<user>\.config\matplotlib matplotlibrc (在Windows文件系统中,这是C:\Users\<user>\AppData\Local\lxss\home\<user>\.config\matplotlib )。

我的matplotlibrc看起来像这样

backend : Agg

但是,如果我这样做

$ cd /home/<user>/.config/matplotlib
$ ls -A

没有出现。

当我尝试

 $ python
 >>> import matplotlib
 >>> matplotlib.get_backend()
 'TkAgg'

很明显,它没有将后端设置为Agg 。 为什么不?

更新:

我已经发现放入backend : AggC:\Users\<user>\AppData\Local\lxss\home\<user>\.config\matplotlib\matplotlibrc backend : Agg仅更改Windows Python中的后端,将Linux Python保留为TkAgg 。 这很奇怪,因为Windows Python应该只使用C:\Users\<user>\AppData\Local\Enthought\Canopy\User\Lib\site-packages\matplotlib\mpl-data\matplotlibrc ,对吧?


My Matplotlib backend keeps reverting to TkAgg. This is a problem because in the Windows Subsystem for Linux (WSL), you can't do GUI stuff, and so I get the error

TclError: no display name and no $DISPLAY environment variable

I've tried adding a matplotlibrc file to /home/<user>/.config/matplotlib (in the Windows filesystem, this is C:\Users\<user>\AppData\Local\lxss\home\<user>\.config\matplotlib).

My matplotlibrc looks like this

backend : Agg

However, if I do this

$ cd /home/<user>/.config/matplotlib
$ ls -A

nothing shows up.

When I try

 $ python
 >>> import matplotlib
 >>> matplotlib.get_backend()
 'TkAgg'

so clearly it's not setting the backend to Agg. Why not?

Update:

I've figured out that putting backend : Agg in C:\Users\<user>\AppData\Local\lxss\home\<user>\.config\matplotlib\matplotlibrc changes the backend in Windows Python only, leaving Linux Python as TkAgg. Which is odd, because Windows Python should only be using C:\Users\<user>\AppData\Local\Enthought\Canopy\User\Lib\site-packages\matplotlib\mpl-data\matplotlibrc, right?


原文:https://stackoverflow.com/questions/40747104
更新时间:2022-04-22 08:04

最满意答案

只需抓住Qt Creator独立包并在某处安装即可。 确保保留用户设置,因为Creator会升级这些设置,之后您的旧版本将无法读取所有这些设置。 您可以复制现有设置的(%APPDATA%/ ... / QtProject或〜/ .config / QtProject IIRC),也可以使用-settingspath / some / dir启动新创建者。


Just grab the Qt Creator stand-alone package and install that somewhere. Do make sure to keep you user settings though, as Creator will upgrade those and your older version will not be able to read all of them afterwards. Either make a copy of (%APPDATA%/.../QtProject or ~/.config/QtProject IIRC) of your existing settings or start the new creator with -settingspath /some/dir.

相关问答

更多
  • 参见QtCreator FAQ 。 (3.0版) 如何重置所有Qt Creator设置? Qt Creator创建以下文件和目录: QtCreator.db QtCreator.ini qtversion.xml toolChains.xml qtcreator qtc-debugging-helper qtc-qmldump 位置取决于平台。 在Linux和其他Unix平台上,这些文件位于〜/ .config / QtProject和〜/ .local / share / data / QtProjec ...
  • QtCreator不是Linux环境,它是一个便携式。 如果您的项目是基于Qt的,则可以安装mtw版本的Qt SDK,它包含Creator(主要)允许在Linux平台上模拟其模拟的使用。 可移植性不是由IDE定义的,而是由您使用的工具链,编译器,库,make实用程序定义的。 您列出的这些名称是头文件,而不是库。 ISO C ++包含兼容编译器应支持的头文件列表。 你可以在这里检查它们: http://en.cppreference.com/w/cpp/header 因此math.h不是C ++头文件,用
  • 发现问题,运行环境中PATH的值是正确的,但LD_LIBRARY_PATH的值缺少32位库(/ usr / lib)的路径。 Found the problem, the value of PATH in Run Environment was correct, but the value of LD_LIBRARY_PATH was missing the path to the 32bit libraries(/usr/lib).
  • 我想我知道是什么导致了这个错误。 这是缺少的公共部分。 您可以通过创建没有公开部分的类来重现该错误 class Foo: public QObject { Q_OBJECT Q_PROPERTY(int c READ c WRITE setC NOTIFY cChanged) Q_PROPERTY(int d READ d WRITE setD NOTIFY dChanged) } 将光标置于Q_PROPERTY上并按Alt + Enter,然后单击生成缺失。 当我将公共部分添加到 ...
  • Qtcreator和rviz不起作用,因为它们需要/usr/lib/x86_64-linux-gnu qt库,但是需要链接到/usr/lib/libQt* (可以使用ldd $(which qtcreator)和ldd $(which rviz) )。 这个烂摊子确实与你的相机包安装有很大关系。 我看到几种解决这个问题的方法: 1.它看起来像你的链接器优先/usr/lib /usr/lib/x86_64-linux-gnu上的/usr/lib/x86_64-linux-gnu 。 检查你的LD_LIBRAR ...
  • 要同时获得优化和可调试构建,可以将CMAKE_BUILD_TYPE设置为RelWithDebInfo 。 To get both optimized and debuggable build, you can set CMAKE_BUILD_TYPE to RelWithDebInfo.
  • 我有与您相同的设置,并在使用以下行更新项目.pro文件后使用了c ++ 11功能: CONFIG += c++11 但是,我认为您的解决方案应该完成同样的事情,因此可能是外部配置问题。 当我包含头文件时,我无法重现错误。 Ok, I seem to have “fixed” it… I got to the point that I was randomly changing parameters just to see what effect it had and all of a sudden thi ...
  • 只需抓住Qt Creator独立包并在某处安装即可。 确保保留用户设置,因为Creator会升级这些设置,之后您的旧版本将无法读取所有这些设置。 您可以复制现有设置的(%APPDATA%/ ... / QtProject或〜/ .config / QtProject IIRC),也可以使用-settingspath / some / dir启动新创建者。 Just grab the Qt Creator stand-alone package and install that somewhere. Do m ...
  • 在“项目”选项卡上,“目标”,“桌面”,“运行”,“运行环境 查找TERM变量。 如果没有找到,添加它和它的值,写xterm On the Projects tab, Targets, Desktop, Run, Run Environment. Look for the TERM variable. If no found, add it and on the value of it, write xterm
  • 此版本的qtCreator(4.1.0)看到了关于使构建目录与项目目录处于同一级别的警告的返回。 在Windows中,这是自动完成的。 我的mac安装不正确。 (我可能已经搞砸了一段时间 - 不记得了)。 所以 - 如果构建目录在项目目录中,则调试失败。 将构建目录移动到与项目目录相同的级别,一切似乎都正常。 您可以在首选项/“构建和运行”对话框中设置默认构建目录。 路径应该以../开头 在设置项目之前,您需要考虑文件夹结构,除非您希望构建文件夹出现在尴尬的地方。 所以,像这样的项目文件夹结构是可以的: 但 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)