This is the third time pygame/livewires has led me to this website, and let it be the last! After installing 'Python 3.1.1' for the book, 'Python Programming for the Absolute Beginner', I installed pygame and then livewires. I tested Pygame by entering
import pygame
And it worked by properly running it. However, when I tested livewires with 'from livewires import games, colors it produced no errors in IDLE, but did produce an error when I properly ran it. The error flicked away so quick I couldn't see it, but I recorded it and paused it just at the right time and got this error:
Traceback (most recent call last):
File "C:\Python31\TEST", line 1, in , <module>
from livewires import games, colors
File "C:\Python34\lib\site-packages\livewires\games.py", line 57, in <module>
import pygame, pygame.image, pygame.nixer, pygame.font, pygame.transform
ImportError: No module named 'pygame.image'
Something I did notice about this is it says Python34, another version I have, in the error not Python31, though the problem may be somewhere else completely.
Please not that it is not my spelling of 'color' that is messing this up. The guy who made the book and bundled it with this special version of livewires seems to have made it spelled 'colors' and not 'colours'. I've tried both and using the British spelling (the one I normally use) just causes an error to appear in IDLE as well.
Please help, hopefully, for the last time.
Thanks in advance, Harry.
You should set your PATH and sys.path(the path modules are imported from) pointing to the same version of Python.
Currently Python 3.1 executable is in your path, but it is using the modules of Python 3.4.
To fix your python executable path: https://docs.python.org/2/using/windows.html#finding-the-python-executable
To fix your sys.path: https://docs.python.org/2/using/windows.html#finding-modules
And one way to have isolated versions of python on your system is using virtual-env: https://virtualenv.pypa.io/en/latest/
Related
I'm having issues running a tkinter program in python 3.5.1, and I really don't understand what's going on. It's never been a problem prior to this point, but now when attempting to run the program in question, I get the following error:
Traceback (most recent call last):
File "C:/Users/Joe/PycharmProjects/Physics2-0/Physics2-0.py", line 1, in <module>
from tkinter import *
File "C:\Python35\lib\tkinter\__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: DLL load failed: The specified module could not be found.
I recently uninstalled and reinstalled python 3.5.1 to make sure that everything was set back to the default way it's supposed to be and was when I started developing the program, because I thought I might have messed something up while trying to work with cx_freeze, and as far as I can tell, everything is as it was before, when the program worked. I have no idea what changed. The import statements for the program in question are below:
from tkinter import *
from tkinter import ttk
from sympy import Symbol
from sympy.solvers import solve
Any and all help is appreciated. I'm at a loss for how to go forward.
EDIT 1: This is getting weirder and weirder. After running the tkinter test like I said in the comments that I did, I tried running the program, and now it will run. I have no clue why.
EDIT 2: The plot thickens. I created a setup.py for cx_freeze to make another attempt at creating an executable of the program. I set my tcl and tk libraries manually as c:\python35\tcl\tcl8.6 and c:\python35\tcl\tk8.6, respectively, and tried to build the executable. It seemed like it worked, but when I ran the executable, it gave me the same error message as it did above, but in a popup error message box, not console. I then tried to do the tkinter test in a python console again, and now when I try import _tkinter I get an error message saying ImportError: DLL load failed: The specified module could not be found. I don't think my computer has ever confused me this much. Someone please help.
I have been searching the web for hours now, found several instances where someone had the same problem, but I seem to be too much of a newb with linux/ubuntu to follow the instructions properly, as none of the given solutions worked.
Whenever I try to run a panda3d sample file from the python shell, I would give me an error saying:
Traceback (most recent call last):
File "/usr/share/panda3d/samples/asteroids/main.py", line 16, in
from direct.showbase.ShowBase import ShowBase
ImportError: No module named 'direct'
What really bugs me is that when I try to execute the .py file directly (without opening it in the IDLE or pycharm) it works just fine.
I know this has been asked before, but I would like to ask for a working step by step solution to be able to import panda3d from pycharm and the IDLE. I have no clue how to get it working, as none of the answers given to this question worked for me.
try to change your PYTHONPATH?
i met a problem like this, and then i modify my PYTHONPATH, and it worked.
This is the third time pygame/livewires has led me to this website, and let it be the last! After installing 'Python 3.1.1' for the book, 'Python Programming for the Absolute Beginner', I installed pygame and then livewires. I tested Pygame by entering
import pygame
And it worked by properly running it. However, when I tested livewires with 'from livewires import games, colors it produced no errors in IDLE, but did produce an error when I properly ran it. The error flicked away so quick I couldn't see it, but I recorded it and paused it just at the right time and got this error:
Traceback (most recent call last):
File "C:\Python31\TEST", line 1, in , <module>
from livewires import games, colors
File "C:\Python34\lib\site-packages\livewires\games.py", line 57, in <module>
import pygame, pygame.image, pygame.nixer, pygame.font, pygame.transform
ImportError: No module named 'pygame.image'
Something I did notice about this is it says Python34, another version I have, in the error not Python31, though the problem may be somewhere else completely.
Please not that it is not my spelling of 'color' that is messing this up. The guy who made the book and bundled it with this special version of livewires seems to have made it spelled 'colors' and not 'colours'. I've tried both and using the British spelling (the one I normally use) just causes an error to appear in IDLE as well.
Please help, hopefully, for the last time.
Thanks in advance, Harry.
You should set your PATH and sys.path(the path modules are imported from) pointing to the same version of Python.
Currently Python 3.1 executable is in your path, but it is using the modules of Python 3.4.
To fix your python executable path: https://docs.python.org/2/using/windows.html#finding-the-python-executable
To fix your sys.path: https://docs.python.org/2/using/windows.html#finding-modules
And one way to have isolated versions of python on your system is using virtual-env: https://virtualenv.pypa.io/en/latest/
I have a Tkinter program that i use for time management. I decided to have it scan my inbox in outlook to check emails for tags, and then based on the tag, add it to my list of tasks to do for the night.
The code i wrote works just fine, but i'm getting an error when I import win32com.client. I can import it in IDLE, but it is having problems importing when i try to run the code with a .bat file, or double clicking the .py file.
I have found several people with similar problems, but from what i can tell, it's having problems with win32api module, or pywin32
Traceback (most recent call last):
File "my_program_filename.py", line 1, in <module>
import win32com.client
File "c:/Python27/lib/site-packages/win32com/__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: The specified module could not be found
I'm really confused. When i get the sys.path it's the same with IDLE as it is running from the .py file with the exception of an added "c:/users/username/desktop/timer" for my .py file.
I'm really lost and haven't had to mess with the system path, but I'm not able to figure out what i need to do to fix this.
What do I need to do to get pywin32 working so I can use win32com.client?
Any help is greatly appreciated. Thanks!
IIRC, the problem was attempting to link to the debug build. I think i had to dupe the release build and rename it to be debug or something.
try building release and see if it "just works". if so, you have a direction to explore
this is an issue of not having the correct paths in the sys.path. If you make sure that all of the pywin32 folders are in the sys.path(If you check in IDLE it can show that the folders are included even when they aren't?!?!?).
You also have to make sure you run your code from inside your Python directory or it will fail to import win32api. I also found that if you do anything in a function that uses pywin32 and you accidentally misspell the function when you call it, the whole import fails without telling you your function is misspelled. You can also navigate to the /Python27/Lib/site-packages/win32com/client folder and run makepy.py to make sure the right Object library is installed.
When you run makepy.py, you select the COM object you want to use and it creates packages specific to what you want to use. I don't fully understand why this is, but once i did this and ran my file from the Python folder it worked! There is a more in depth explanation on how to get this working right here.
I found this link to be the solution rather than the win32com/client as indicated above: win32com import error python 3.4
in my case typing in cmd:
python C:\Python27\Scripts\pywin32_postinstall.py -install
I hope this helps
I'm running Python 2.7, with the latest version of GTK installed.
I'm trying to import gtk with the following line of code:
import gtk
It is throwing the following error:
Traceback (most recent call last): File
"C:\GTKTutorial\tutorial.py", line 3, in
import gtk File
"C:\Python27\lib\site-packages\gtk-2.0\gtk__init__.py", line 40, in
from gtk import _gtk ImportError: DLL load failed: The specified
procedure could not be found.
How do I fix this? import pygtk is working, and I have Glade 3.8.0 installed.
Where did you get the PyGTK installer from? Try using this one: http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/pygtk-all-in-one-2.22.6.win32-py2.7.msi
I just spent 3 days debugging this issue on my computer. This problem can have many root causes because importing gtk actually causes a lot of DLLs being loaded. If any of them fails, you get the same error message. For me, the break-through was
http://www.dependencywalker.com/
which I used to profile the command
python -i -c "import gtk"
On my PC, a wrong version of zlib1.dll was in the system32 directory, which prevented the right one in gtk\bin from loading. And it did that even though the first entry in my path pointed to gtk\bin.
I deleted the zlib1.dll from system32 (the application that put it there deserves to die) and the import worked fine. Your problem may be different, but dependency walker probably can give you a hint on what is going wrong.
Windows can have other reasons for loading a DLL other than the one you put in your directory or path. I found the blog
http://www.davidlenihan.com/2007/07/winsxs.html
useful. It describes Microsoft's solution for managing many versions of DLLs, and how to troubleshoot problems with it.