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 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 first time I have attempted to use anything other than what's provided by python.
I have recently gotten into pythons provided Tkinter, though due to some issues I decided to use another GUI, and heard that PyQt was highly recommended, so I downloaded that and looked into various tutorials. In these tutorials, I cannot seem to execute any of the import statements in said tutorials that relate to PyQt, primarily PyQt5 (I have checked I have the correct version number by the way).
So for instance:
import PyQt5
raises the error:
Traceback (most recent call last):
File "/Users/MEBO/PycharmProjects/Music/testing.py", line 1, in <module>
import Qt
ImportError: No module named 'Qt'
[Finished in 0.1s with exit code 1]
I have a lot of research into this. I've heard people talk of using pip to install modules, and I have done this be safe (as well as downloading it from the internet), I've tried changing the project interpreter to versions Python3/ 2.7/ 2.6, appending the path name to the sys.path directory, (which I really know nothing about to be honest, I was hoping I'd get lucky), though nothing seems to work.
Are you supposed to be able to just import a module off the bat, or do you have to set some things up first?
For windows download the package and extract it to (path where python installed)\Python27\Lib and then try to import.
Specific to PyQt
This package cannot just be downloaded and imported, it must be built because it is not pure python, it uses Qt (C++) and requires dependancies. Read this tutorial on installation.
There is also a very complete python package distribution, Anaconda, that includes pyqt and much more. Almost all the packages I ever looked at are in there.
In general to pure python code
In other cases, if you place modules/code that has been download into the directory that your python script is run from, you can import off the bat, or you can append/insert any folder to the sys.path.
# importer will search here last
sys.path.append('/path/to/code/')
# importer will search here second, right after script's directory
# this can be useful to override a module temporarily...
sys.path.insert(1,'/path/to/code/')
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.