In order to start building a gui I've decided to install wxPython, however I can't get it working. I run python 2.7.6 (in IDLE it shows: Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win32) and it works fine.
When I however try to install a 32 bit or 64 bit version of wxPython from http://www.wxpython.org/download.php it doesn't work, meaning that when I run:
import wx
I get the following message:
Traceback (most recent call last):
File "C:\Users\****\Desktop\Python GUI test\test1.py", line 2, in <module>
import wx
ImportError: No module named wx
I think it might go wrong with the place where it installs wxPython. Normally however it uses the right directory automatically. It tries to install in the following dir:
C:\Users\****\AppData\Local\Enthought\Canopy32\User\Lib\site-packages
Which is in a program called Canopy which I once installed but don't know how to get rid off. I've installed it in this dir and I've also installed it within the dir where Python is installed:
C:\Python27\Lib\site-packages
Both of these locations don't work.
Anyone has an idea where things go wrong?
I would suggest to clean up your installations. Canopy is part of Enthought, so if you don't need this anymore de-install it, I would think you can do that from: Control Panel\All Control Panel Items\Programs and Features
Then re/install the Python version you want to use, would suggest 2.7.8 32 bit and then install wxPython 3.0.1 32 bit for Python 2.7.
To test it do not use "Idle" as it is written in Tkinter, which will cause conflicts with wxPython. Just test it with
c:\Python27\python.exe
import wx
Related
I am importing two python modules on my school computer (I cannot use cmd, I do not have enough experience with powershell), pygame and pyglet. I imported these modules last year and had no problems, this year I have started having problems. I tried reinstalling them.
I have imported them via pip.
import pip
pip.main(["install", "--user", "pygame"])
and
import pip
pip.main(["install", "--user", "pyglet"])
It says that this requirement has already been meet.
When I import it into my code it says
I have tried other methods and they all return the same result.
What can I do?
If restarting vscode doesn't work to cause pylance to find new packages, it sounds like there's a mismatch between the interpreter you're using to run your programs (and where you installed the packages via pip) and the interpreter vscode/pylance is using for language support.
With those restrictions, try this:
First, create a script with
import sys
print(sys.version)
print(sys.executable)
and run it (however you're running scripts).
You should get output like:
3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
C:\Python\Python310\python.exe
Then, in the bottom right of vscode there's a statusbar and at the right side you should see something like:
Here it shows that vscode is using the 3.10.2 64-bit version of the interpreter.
If you click the version label (3.10.2 64-bit in my case), you should get a pop-up at the top of your screen, like:
Make sure you select the interpreter that you're using (as identified by the output of that simple 3-line script -- both the interpreter version and the path).
For me this was a version mismatch: VSCode was using a different interpreter version (3.10) than the packages were installed for (3.9).
You can correct this by clicking the Python version in the status bar (to the right of the word Python). Multiple options should show up, switching to 3.8.9 worked for me.
Ok, I'm trying to install python 3.9 in my computer. The only thing I know about computers is programming, and I'm starting with Python. I really don't understand much of anywhere before that, so that's why I couldn't get what I'm looking for in other StackOverflow questions and so on. I have a hard time in that. Therefore, I'll describe exactly what I did:
I went to https://www.python.org/ and downloaded Python 3.9 (that button in the middle).
After it finished downloading, I opened it and went through the installation window. After it was done, I went to my Terminal (after I figured out what it was) and typed which python. This is where the problem starts; I got a pretty neutral return (just the path):
/usr/bin/python
After that, I did python. Then there was a problem:
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.
Python 2.7.16 (default, Apr 17 2020, 18:29:03)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
All I understand is that the computer still has Python 2.7.16 installed (which, if I understand correctly, is a default for Mac), and not the 3.9. In the tutorial I was watching, this didn't happen... What can I do?
EDIT: By the way, the commands python3.9 and python3.9.0 gave the same error message:
>>> python3.9
File "<stdin>", line 1
python3.9
^
SyntaxError: invalid syntax
>>> python3.9.0
File "<stdin>", line 1
python3.9.0
^
SyntaxError: invalid syntax
Errors and lines beginning with >>> suggest you're still inside Python2 interpreter. You need to exit it before trying to run Python3. You can do that by pressing the Ctrl and d buttons on your keyboard at the same time, or typing exit().
After exiting, you should be able to run python3.
looks like your python is linked to python2.7 instead of python3.
just type python3 on commandline, this should solve your problem. you can check the version by typing python3 --version on commandline.
the same should work for pip3
The best easy way is to use anadonda based python or intel based.
Anaconda based python for MacOS
This should work for you.
I've been trying to run a bot for Super Hexagon (Just for fun), but when I try to run the module in IDLE 2.7.11 (32 bit) I get the error
Traceback (most recent call last) :
File "C:\Users(Me)\Desktop\Super-Hexagon-Bot\super_hexagon_bot.py", line 8, in < module >
import win32ui
ImportError: No module named win32ui
Unfortunately, right now I'm streaming my desktop to my Macbook, so I can't copy the code, but here's an image of the part the program has an error with.
I have 64 bit Windows 8, so the win32ui is most likely the problem, but I'm not sure how to change the code to accomodate 64 bit. Any suggestions?
I think the problem is not the the BIT version from your Windows PC.
It seems to me, that you have not installed he module win32ui.
After searching the web, I have found, the module pywin32, which should include all necessary WIN thinks.
You can install it via pip, easy_install of with these MSI installer:
http://sourceforge.net/projects/pywin32/files/pywin32/
Please use the newest and correct version.
But I think you have to change the code:
Sorry I have no Windows PC, so I could not try it, maybe something like that:
from pywin32 import *
It's most likely the Python libraries you are using here, is causing the issue. There is 64 bit build for python win32ui.
http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/
Download and install one of then and set the build path and import accordingly.
I am trying to install and use PyGame. I am using Python 3.3.2 and Pygame "3.3 pygame-1.9.2a0" according to the installer. I downloaded it from https://bitbucket.org/pygame/pygame/downloads. I used an easy install, and after next-next type install, I opened the Python 3.3.2 Shell and typed "import pygame". I got this error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pygame
ImportError: No module named 'pygame'
>>> import sys; print sys.path
SyntaxError: invalid syntax
I am also trying to install it with the PyCharm IDE, but I have NO clue how to do that either. The installer I'm using may be for 32 bit, which wouldn't be compatible with my 64 bit installation of Python, but I don't know how to tell and if so is there even a 64 bit version of PyGame for 64 bit? If anyone knows how to install PyGame for Python 3.3.2 please let me know. Thank you for your time.
If your python is a 64 bit version the binary install for the 32 bit will not work. However, there is a 64 bit version here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
If you're worried because they're unofficial don't. I have used many installations from that link for my 64 bit python and they're working great.
Currently, pygame is not available for 64 bit Python (or so it seems on Pygame Site).
The one you installed maybe 32 bit & thus causing the ImportError.
In Python 3.x, print is a function & hence the SyntaxError.
Pycharm for Python 3.x is available Pycharm Download
I would recommend using Python 3.x (32 bit) because most of the libraries seem to be compatible with it & also, 64 bit version doesn't provide much performance benefit as such.
I personally use PyScripter IDE
This maybe very handy at times - Very useful precompiled binaries for several libraries
From pygame website:
windows 64bit users note: use the 32bit python with this 32bit pygame.
So either donwload a 32bit python, then install with the 32bit pygame installer, or download the unofficial 64bit pygame build at here.
Ever time I use PyCharm, I go to File > Settings > Project: (project name) > Interpreter > Plus Icon > (search pygame and click install package) This is because I think that you are using a pycharm venv and I think that that isolates outer packages so I do it this way
I downloaded and installed this version of wxPython for use with my Python 2.6 installation:
http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.9.1-py26.exe
When I run Python and try to import wx, I get the following error:
C:\Program Files\Console2>python
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.py", line 45, in <module>
from wx._core import *
File "c:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 4, in <module>
import _core_
ImportError: DLL load failed: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
>>>
I have already tried removing wxPython and installing again and I got the same error. How can I fix this problem?
I was getting the same error.
After some googling found this link to MSVC++ 2008 Redestributable and installed it.
That solved the problem.
Hate to say this, but I had the same problem, and and import worked fine after a reboot.
Copy the Microsoft C runtime library v.9 files and manifest. That is, msvcr90.dll and microsoft.vc90.crt.manifest from folder python to the folder wx, tha is, folder which contains failed to start DLLs.
Or install the Visual C++ 2008 Redistributable Package.
From looking for "application configuration is incorrect" in the wxPython trac system, the only reference that might make sense is a 64-bit vs 32-bit compatibility issue.
Otherwise, I'd say Brian's answer of trying ANSI is pretty good.
BTW, if you try uninstalling again, make go into the site-packages folder and make sure all the wx and wxPython stuff is deleted.
Try the ANSI version instead of the Unicode one. IIRC it needs to match the Python 2.6 install to work properly.
I too have the same issue.Better install "Portable Python" IDE which comes with some nice modules including wxPython .You can start coding GUI immediately without the need to download a separate wxPython.The link ,
http://www.portablepython.com/
Maybe too late, but I had the same problem and solved that by downloading that from their own website : wxPython2.8-win64-unicode-py27
In my case it initially wanted to setup in somewhere else than my python folder. So I changed it to be in ../python27/Lib/SitePackages/
Then it worked properly.
I hope it helps.
Another late answer, but I recently had issues (8/14) and my solution was to use the 32-bit instead of 64-bit wxPython version.
you try to use the module wxpython 2.8.12.1 version, select the version of your python. you can download it here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#wxpython