So I'm using python 3.3 and recently I have tried to install wxpython and wxwidgets.
Synaptic package manager shows that wxversion, wxtools and wxgtk2.8 are all installed. When I use the python idle I get an import error however when I use iPython (command line with auto complete etc...) it happily runs the code.
What's going on?
Error Message:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module> import wx
ImportError: No module named 'wx'
IPython must be running Python 2.x because wxPython 2.8.x ONLY works with Python 2.x. If you want to use wxPython in Python 3, you have to use wxPython 2.9-Phoenix. Please note the Phoenix is kind of alpha in that ONLY the core widgets are currently available in it.
You can read more about it and download it from here:
http://wiki.wxpython.org/ProjectPhoenix
in your python shell at the very top, it will tell you what bit your python runs on. It's either 32bit or 64 bit. now once you have that info wxpython has two different bit varients depending on what python version your running, again either 32bit or 64 bit. If you have the python 32bit version you must use the wxpthon 32bit for the import to work.
I had this mistake also and figured it out this way. Good Luck!!
First let's See what version of Python we're running:
python --version
Looks like we have Python running version 3.
Python 3.3.0
That won't work.
Remove Python 3:
sudo apt-get remove python3
Let's reinstall Python but version 2.7:
sudo apt-get install python2.7 wx-common python-wxtools python-wxgtk3.0
Related
I have recently bought a new laptop and was viewing some python projects of mine which I made on my pc. For one of them I use the python-bitvavo-api library which I installed using pip3 install python-bitvavo-api. The version I installed is 1.2.2 which is the latest on their website.
Now when I try to import it using this code: from python_bitvavo_api.bitvavo import Bitvavo, I get the following error:
Traceback (most recent call last):
File "C:\Users\indig\OneDrive\Documenten\Python Projects\Personal\Cryptone\Cryptone.py", line 6, in <module>
from python_bitvavo_api.bitvavo import Bitvavo
ModuleNotFoundError: No module named 'python_bitvavo_api'
I read online that it may occur when using multiple python versions, Im only using 1 and thats python 3.7
Btw. I have the same error with the Pillow module, so it might be a setting in visual studio that I dont know of. Anyway, someone please help. If you need more details please ask.
How are you running it? From the terminal or from VS?
You can also check the installed libraries running the command pip list
Short version: Python 3 is unable to use tkinter on my iMac.
Details and useful info: I'm on macOS Mojave, Version 10.14.3 (18D109). (I can't upgrade for a while yet because of software that won't run on the newer versions.)
In my scripts I'm using #!/usr/bin/env python3 and when I get to the line import tk as tkinter I get this error:
Traceback (most recent call last):
File "/Users/hal/Documents/Dev/HalPy/TestScript.py", line 5, in <module>
import tkinter
File "/Users/hal/.pyenv/versions/3.7.3/lib/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
When I tested it, from the command line, I typed python and got the Python shell and the version info (Python 3.7.3 (default, Apr 11 2020, 02:53:05)). Then I tried import tkinter as tk and I get this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hal/.pyenv/versions/3.7.3/lib/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I see the module when I drop into the Help mode and type modules and tkinter shows up in the list of modules. Just in case, I tried installing it with pip, but it wouldn't install (which is what I expected).
So what do I need to do to get Python 3 to recognize tkinter? (Just in case it matters, Python 2 with Tkinter does work.)
Also, I have looked at this question and this one and this is NOT a duplicate. (First note that neither has an accepted answer.) The first one involves reinstalling, and the focus seems to be on Windows, and this is on macOS, which includes it pre-installed. I'm a bit concerned what reinstalling it would do. The 2nd question is having problems because it's being run within the XCode framework and one element of the issue is the wrong shebang and I'm already using the one the answer suggests.
you can find your answer here:
https://blog.lanzani.nl/2020/install-tkinter-macos/
If you are using a Python from any current python.org Python installer for macOS (3.9.0+, 3.8.0+, or 3.7.2+), no further action is needed to use IDLE or tkinter. A built-in version of Tcl/Tk 8.6 will be used.
If you are using macOS 10.6 or later, the Apple-supplied Tcl/Tk 8.5 has serious bugs that can cause application crashes. If you wish to use IDLE or Tkinter, do not use the Apple-supplied Pythons. Instead, install and use a newer version of Python from python.org or a third-party distributor that supplies or links with a newer version of Tcl/Tk.
for my master thesis, I have to render some maps from OpenStreetMap information. Unfortunately, I'm not able to install mapnik.
In the manual (https://github.com/mapnik/mapnik/wiki/WindowsInstallation) it said I should Add ";C:\mapnik-v2.2.0\lib" to the PATH variable. In my case it is "C:\Users\User\Mapnik\lib". I cloned the git repo and updated it to v3.0.23. Like it said here: https://mapnik.org/pages/downloads.html
But in this location, I don't have lib. Also, I don't have bin. So I'm a little bit confused about how to install mapnik.
I would really appreciate your help.
Some more Information: OS is windows 10, For Python, I'm using Anaconda with a 2.7 Instance just for mapnik... even if I read, that I could go with python 3. For the rest of my code, I go with Python 3.8. For sure I would prefer to stay at 3.8 but if it only works with 2.7 I would also use that.
Error message: "(Mapnik) C:\Users\User\Mapnik\demo\python>python rundemo.py
Traceback (most recent call last):
File "rundemo.py", line 25, in
import mapnik
ImportError: No module named mapnik"
I've been trying to install PyGame with little success. I downloaded the
pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg
version of PyGame from this link and installed it using the wizard, but when I typed import pygame into the IDLE I got the following message.
$ import pygame
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pygame
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/__init__.py", line 95, in <module>
from pygame.base import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: no matching architecture in universal wrapper
What did I do wrong?
Also, what are the prerequisites for PyGame? I'm doing all this on a new computer and I've hardly downloaded anything.
I'm running OS X Version 10.8.2.
I know this thread is a little old, but thought I'd share my experience on this subject...
I'm using a 64-bit MacBook Pro running OS Mavericks and python 2.7.
Steps:
If you've installed a few different versions of pygame while trying to get the darn thing to import and work successfully, make sure you delete/uninstall all of these to get a fresh start. I did a simple search in the terminal to see where all of the various pygame folders where located:
In Terminal: sudo find / -iname "pygame"
The results show a list of all the pygame directories, these are the folders that you want to delete. Note, I created a new tab in terminal to do this so I can reference the directories from the search on the previous tab and easily copy each directory without having to do another search to remember where they are:
In Terminal: sudo rm -R -i path/pygame
Also note, you can take the -i out of the above code and it won't confirm the deletion of certain files, but BE REALLY CAREFUL when deleting full directories from the terminal.
Once your machine is clean of all previous pygame installations, make sure you have python 2.7 from python.org, NOT IDLE (default Mac Python Interpreter)! This is very important. I use PyCharm and it rocks! Also, choose the version that works on a 32-bit machine and 64-bit machine - this way you won't have issues with the pygame 32-bit installer on your 64-bit machine. I tried same installation process but with the 64-bit only python 2.7 installation and it didn't work. Link provided below:
Download 32/64-bit Python 2.7
Next, download the 32-bit pygame file for OS X 10.3 and beyond and run the mpkg file created from the dmg. Link provided below.
Download pygame 1.910 release for python 2.7
You should now have a working pygame installation in your python 2.7 package library. Enjoy.
Did you install python from python.org? Or use the one that came with OS X?
If you used the one supplied by Apple, you must download the one from python.org first, then install using that package. Or you can try the Lion-pygame package (the link is at the bottom of the Macintosh section of the download page), but it may be incompatible.
Did you download python 64-bit or python 32-bit?
This can cause major problems if you don't have the right one, if you have 64-bit you can download pygame 64-bit from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Being quite cavalier I went for the latest version of Python (3.2.2)
Unfortunately it lacks the matplotlib that I desperately need.
I have downloaded python 2.7.
My simple question is weather I have to uninstall python3.2 or can I leave it on my windows 64 system?
you can keep the python 3.2 installation, but you will have to be carefull about which version you launch (by making the call explicit). you can always check the python version in a script by doing:
import sys
print sys.version
If you have no particular use of python 3.2, I recommend uninstalling it.
I'm not sure if there's a difference on python in windows but on mac and linux I simply call older versions using
python2.6 or python2.7
It seems to keep all the versions I previously had before. Maybe try running the above command and seeing if it works on windows and if it does just change the symbolic link 'python' is pointing to.