简体   繁体   English

在Python27中安装wxPython

[英]wxPython install in Python27

I've been trying to install wxPython in Python27. 我一直在尝试在Python27中安装wxPython。

I typed below command in Python27 dir, and installed it. 我在Python27目录中键入以下命令,并安装了它。

pip install wxPython

在此处输入图片说明

I expected the wxPython would be installed in Python27. 我希望将wxPython安装在Python27中。

But, the wxPython doesn't work in Python27. 但是,wxPython在Python27中不起作用。

When I tried to import the wx, I got below error. 当我尝试导入wx时,出现以下错误。

在此处输入图片说明

On the other hand, it works for Python3. 另一方面,它适用于Python3。

How could I get proper wxPython version for Python27? 如何获得适用于Python27的wxPython版本?

The installed wx version is this. 安装的wx版本是这个。

在此处输入图片说明

This is the result of the command python -m pip install wxPython . 这是命令python -m pip install wxPython

在此处输入图片说明

Think I understand whats happening now: Your Python 3.7 almost always "wins" against 2.7 (due to the way its installed; we will not know because we cannot see how you activate one over the other according to your screenshots). 想想我明白现在发生了什么:您的Python 3.7几乎总是比2.7赢(由于其安装方式;我们不知道,因为我们无法根据屏幕截图看到您如何激活一个)。 At any rate, when you do 无论如何,当您这样做

C:\Python27\python.exe

you will run Python 2.7. 您将运行Python 2.7。 However, when you do 但是,当您这样做时

C:\Python27\pip

this will call the pip in the 3.7 (!), because it has precedence on %PATH% before the 2.7 one. 这将在3.7(!)中称为pip,因为它在%PATH%之前优先于2.7。 If you would do C:\\Python27\\scripts\\pip.exe you would call pip/install into 2.7! 如果您执行C:\\Python27\\scripts\\pip.exe可以将pip / install调用到2.7! This is by the way what @RobinDunn suggested! 这就是@RobinDunn建议的方式! If we look at your newest screenshot, we can see already that both 2.7 and 3.7 have wxPython installed. 如果我们查看最新的屏幕截图,我们已经可以看到2.7和3.7都安装了wxPython。

So, accordingly, if you try: 因此,因此,如果您尝试:

C:\Python27\python.exe -c "import wx;print(wx.version())"

you should indeed be able to prove to yourself that the 2.7 has its wx properly running! 您确实应该能够向自己证明2.7的wx正常运行!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM