如何正确安装 wxPython?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32284938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to properly install wxPython?
提问by oisinvg
So I was looking around at different things to do on Python, like code for flashing text or a timer, but when I copied them into my window, there were constant syntax errors. Now, maybe you're not meant to copy them straight in, but one error I got was 'no module named wx'. I learned that I could get that module by installing wxPython. Problem is, I've tried all 4 options and none of them have worked for me. Which one do I download and how do I set it up using Windows?
所以我四处寻找可以在 Python 上做的不同的事情,比如用于闪烁文本或计时器的代码,但是当我将它们复制到我的窗口时,会出现不断的语法错误。现在,也许您不打算直接复制它们,但是我遇到的一个错误是“没有名为 wx 的模块”。我了解到我可以通过安装 wxPython 来获取该模块。问题是,我已经尝试了所有 4 个选项,但没有一个对我有用。我应该下载哪一个?如何使用 Windows 进行设置?
Thanks
谢谢
回答by rgammans
You need to ensure the versions of your wxPython download matches your installed python language library.
您需要确保您下载的 wxPython 版本与您安装的 Python 语言库相匹配。
The current downloads wxPython downloadsdoesn't show any libraries built against python 3. I Believe the python 3 porting projectis still ongoing.
当前下载wxPython 下载没有显示任何针对 python 3 构建的库。我相信python 3 移植项目仍在进行中。
If you are not sure of what you are doing I would stick with the 32bit version on windows as there are some Python libraries (ie IIRC, MySQLdb) which don't work with 64 bit python.
如果您不确定自己在做什么,我会坚持在 Windows 上使用 32 位版本,因为有一些 Python 库(即 IIRC、MySQLdb)不适用于 64 位 Python。
So you would then need to download python2.7for windows x86 and "wxPython3.0-win32-py27 32-bit Python 2.7"
所以你需要下载 python2.7for windows x86 和 "wxPython3.0-win32-py27 32-bit Python 2.7"
回答by Sergei
As per home page instruction:
根据主页说明:
Make sure you have at least version 6.0.8 of pip and 12.0.5 for setuptools.
确保您至少有 6.0.8 版的 pip 和 12.0.5 版的 setuptools。
Install requirements for Linux as outlined in the readme.rst at:
安装 Linux 的要求,如 readme.rst 中所述:
https://github.com/wxWidgets/Phoenix/blob/master/README.rst
Install wxPython-Phoenix (Linux):
安装 wxPython-Phoenix (Linux):
sudo pip install --upgrade --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
Install wxPython-Phoenix (Windows, use the appropriate script folder):
安装 wxPython-Phoenix(Windows,使用适当的脚本文件夹):
C:\python27\scripts\pip.exe install --upgrade --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
回答by Guiloga
To install wxPython GUI library correctly go to the following page (https://wxpython.org/Phoenix/snapshot-builds/), which contains snapshots builds of wxPython library (Phoenix version) depending on your os and version of Python you want to work.
要正确安装 wxPython GUI 库,请转到以下页面(https://wxpython.org/Phoenix/snapshot-builds/),其中包含 wxPython 库(Phoenix 版本)的快照构建,具体取决于您要安装的操作系统和 Python 版本工作。
Then when you downloaded the proper package for your system and python version, simply install it by using pip. In my case I've choosen that one (wxPython_Phoenix-3.0.3.dev2811+ecc4797-cp36-cp36m-win_amd64.whl):
然后当你为你的系统和 python 版本下载了合适的包时,只需使用 pip 安装它。就我而言,我选择了那个(wxPython_Phoenix-3.0.3.dev2811+ecc4797-cp36-cp36m-win_amd64.whl):
pip install wxPython_Phoenix-3.0.3.dev2811+ecc4797-cp36-cp36m-win_amd64.whl
To check that it has been installed sucessfully on the site-packages folder for your current python environment write:
要检查它是否已成功安装在当前 python 环境的 site-packages 文件夹中,请编写:
pip freeze
It's all!
这一切!
回答by Kyle Strand
It's on PyPI. As of wxPython 4, Python 3 is supported.
它在 PyPI 上。从 wxPython 4 开始,支持 Python 3。
Unfortunately, PyPI has a package called wx
that is stuck at version 3.0.3; be sure to install the package named wxpython
instead.
不幸的是,PyPI 有一个名为wx
3.0.3 的包。一定要安装命名的包wxpython
。
pip install wxpython
Please notethat pip
will automatically build wxWidgets for you, but it will notinstall wxWidgets system dependencies such as GTK and OpenGLu. If the above command exits with an error, look above for a message like this:
请注意,它pip
会自动为您构建 wxWidgets,但不会安装 wxWidgets 系统依赖项,例如 GTK 和 OpenGLu。如果上述命令退出并出现错误,请在上方查找如下消息:
checking for <something>... not found
checking for <something>... no
configure: error: <prereq> libraries not available
Error running configure
ERROR: failed building widgets
This should give you information about at least one of the packages your system is missing.
这应该为您提供有关您的系统缺少的至少一个软件包的信息。
The "official" list of prerequisites from the wxWidgets sourceis:
来自wxWidgets 源的“官方”先决条件列表是:
- dpkg-dev
- build-essential
- libjpeg-dev
- libtiff-dev
- libsdl1.2-dev
- libgstreamer-plugins-base0.10-dev # or 1.0 if available
- libnotify-dev
- freeglut3
- freeglut3-dev
- libsm-dev
- libgtk-3-dev
- libwebkitgtk-3.0-dev # or libwebkit2gtk-4.0-dev if available
- libxtst-dev
- dpkg-dev
- 构建必不可少的
- libjpeg-dev
- libtiff-dev
- libsdl1.2-dev
- libgstreamer-plugins-base0.10-dev # 或 1.0(如果可用)
- libnotify-dev
- freeglut3
- freeglut3-dev
- libsm-dev
- libgtk-3-dev
- libwebkitgtk-3.0-dev # 或 libwebkit2gtk-4.0-dev 如果可用
- libxtst-dev
The actual package names provided by your package manager may not match these exactly, and to be honest, I don't really know the best way to query a package manager to determine what packages provide the libraries you need.
您的包管理器提供的实际包名称可能与这些不完全匹配,老实说,我真的不知道查询包管理器以确定哪些包提供您需要的库的最佳方法。
回答by sjrk
3 steps to install wx-widgets and pygame in python IDLE
在python IDLE中安装wx-widgets和pygame的3个步骤
- Install python 3xxx in your system opting (Add 3xxx to your path).
- open python CLI to see whether python is working or not.
- then open command prompt (CMD).
- type PIP to see whether pip is installed or not.
- enter command : pip install wheel
- enter command : pip install pygame
- To install wxpython enter command : pip install -U wxPython
- 在您的系统中安装 python 3xxx 选择(将 3xxx 添加到您的路径)。
- 打开 python CLI 以查看 python 是否正常工作。
- 然后打开命令提示符(CMD)。
- 输入 PIP 以查看是否安装了 pip。
- 输入命令:pip install wheel
- 输入命令:pip install pygame
- 安装 wxpython 输入命令:pip install -U wxPython
Thats all !!
就这样 !!
回答by Jyoti Panda
Check the version of wxpython and the version of python you have in your machine. For python 2.7 use wxPython3.0-win32-3.0.2.0-py27 package
检查wxpython的版本和你机器上的python版本。对于 python 2.7 使用 wxPython3.0-win32-3.0.2.0-py27 包
回答by Tokaalmighty
I installed wxPython as part of the PsychoPy experiment builder dependencies, and had considerable trouble getting it to install properly as well initially. But this was what worked for me at the end. I use Ubuntu 16.04, python 3.5, pip3 19.0.3
我将 wxPython 作为 PsychoPy 实验构建器依赖项的一部分安装,并且在最初正确安装它时遇到了相当大的麻烦。但这最终对我有用。我使用 Ubuntu 16.04、python 3.5、pip3 19.0.3
pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython --user