I have Python 3.5.1 for Windows (official python.org installer) installed and it seems to be missing tkinter. For example:
C:\Users\kostya>python
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from tkinter import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'tkinter'
Does anyone have an idea about were I can download the package?
The installer has an option "[X] install tkinter, IDLE, turtle". It should be on by default, but you might have clicked it off. If you run the installer again, you should see an option to repair. That should get you an option to see if the box is checked. Must sure it is and 'repair'.
If using Windows, open settings and got to Apps and features:
Select Modify.
The click Modify (again) and then check the [x] Tcl/Tk box.
Related
Context: A Windows 10 attempt to install and test python hid per instructions:
pip install hid
The test to import the module failed:
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import hid
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\student\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\hid\__init__.py", line 30, in <module>
raise ImportError(error)
ImportError: Unable to load any of the following libraries:libhidapi-hidraw.so libhidapi-hidraw.so.0 libhidapi-libusb.so libhidapi-libusb.so.0 libhidapi-iohidmanager.so libhidapi-iohidmanager.so.0 libhidapi.dylib hidapi.dll libhidapi-0.dll
Released hidapi-win.zip includes pre-compiled:
hidapi.dll
hidapi.lib
Question: What is the thought process & facts necessary to determine the proper location to install the two files? Assume a recent new install of Windows 10 and Python 3.8
First, you need to Unblock them. Right-clik > Properties > Unblock
Place both files in the same folder where python.exe is.
The location of python exe can be found in the command line as where python
Paste the .dll and .lib file inside the Windows/System32 folder. After that restart the terminal and the hid module should find the library without a problem
I got the same issue. There was another version of hid installed in my system, after deleting the hid folder issue got solved. Check the version of hid still exits in this below "site-packages" folder.
C:\Users\OPERATOR\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages
The command line application shoogle (https://github.com/tokland/shoogle) which exposes google api services at a terminal command line requires python3 but the ubuntu 16 default python is 2.7.
I have tried alias and calling the shoogle app from subprocess in a python3 shell but (of course) the os still provides the default. I have been reluctant to make system wide changes to .bashrc or PYTHONPATH e.g. as so many other resource expect 2.7. But I am currently using this on a virtual machine so if it does break I can recover. That seems the only option but impractical in a production environment.
I've found very little shoogle help online (the author suggests SO etc. for support) so if any one has any experience with shoogle or suggestions to get the requiured python version I'd be happy to hear.
Running shoogle from a python3 interpreter finds the 2.7 files:
3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609]
Python Type "help", "copyright", "credits" or "license" for more information.
from subprocess import call
call (['shoogle', 'show'])
Traceback (most recent call last):
File "/usr/local/bin/shoogle", line 11, in <module>
import shoogle
File "/usr/local/lib/python2.7/dist-packages/shoogle/__init__.py", line 5,
in <module> from .shoogle import *
File "/usr/local/lib/python2.7/dist-packages/shoogle/shoogle.py", line 14, in <module>
from . import commands
File "/usr/local/lib/python2.7/dist-packages/shoogle/commands/__init__.py", line 2, in <module>
from . import execute
Using #Surest Texans suggestions I uninstalled the shoogle app and used pip3 install to reinstall. Now the application works as expected when called from the command line.
I am running Ubuntu 16 and have both python 2 and 3. I have downloaded wxpython and it works with the python2 interpreter but not 3. I get
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>>
and
Python 3.5.2 (default, Sep 14 2017, 22:51:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'wx'
What do I need to do to get installed for python 3?
A similar situation arises on Fedora 25, on which I was able to solve this. Your mileage may vary on Ubuntu.
First note that wxPython is available in two major versions, let's call them wx3 and wx4. You can identify your running version through import wx; print(wx.version()). The version string on Fedora 25 reads '3.0.2.0 gtk3 (classic)', i.e. a brand of wx3. On sourceforge these versions are known as 'wxPython' and 'wxPython4', and wxpython.org calls wx4 'phoenix'.
Inspecting the source code of wx3 you will note that wx3's syntax is incompatible with python3. Conversely, wx4 is compatible both with python2.7 and python3.
wx4 doesn't seem to be available on Fedora 25, therefore python3 can't run any wx out-of-the-box. Ubuntu may or may not have the same issue.
The following worked for me to install wx4 in a python3 virtual environment:
pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/fedora-26 wxPython
I presume the answer to your question would be
pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython
In case you need to port a (py2, wx3) application to python3, you would be wise creating an intermediate step: (py2, wx3) -> (py2, wx4) -> (py3, wx4), noting that (py3, wx3) is an impossibility.
To create the (py2, wx4) environment was more cumbersome for me, because the above pip install command fails to find header files when run using pip2.
What ended up working for me was to download the 4.0.0b2 source https://pypi.python.org/packages/bc/6f/f7bb525517557e1c596bf22ef3f242b87afaeab57c9ad460cb94b3b0714e/wxPython-4.0.0b2.tar.gz#md5=2e3716205da8f52d8039095d14534bf7
and follow the build instructions https://github.com/wxWidgets/Phoenix/blob/master/README.rst , from which I only used the build command python build.py dox etg --nodoc sip build .
After building, you need to tell your python2 where to find the wx4 library. I ended up doing that by creating a virtualenv, and creating a symbolic link like so:
/home/user/venv/lib/python2.7/site-packages/wx -> /home/user/downloads/wxPython/wxPython-4.0.0b2/wx
That latter directory cointaining the result of the build.
I am having a problem with "import "serial".
I am running Python 3.3.2 on Windows (XP) and have installed pyserial 2.5 from the Windows installer pyserial-2.5.win32.exe. The traceback below shows what happens.
C:\hal\Python>python
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python33\lib\site-packages\serial\__init__.py", line 19, in <module>
from serialwin32 import *
ImportError: No module named 'serialwin32'
>>>
The python interpreter finds and runs c:\python33\lib\site-packages\serial\ __init__.py, which checks the os name, finds that it is "nt" and executes "from serialwin32 import *". That fails.
The file serialwin32.py is in the \serial directory with __init__.py.
I tried this with Python 3.1.1 and 3.2.3 and got the same results.
I read that pyserial 2.5 is not dependent on pywin32 but I have it installed anyway; win32, build 18, for Python 3.3.
Has anyone seen this problem or know what I may be doing wrong?
Thanks
Why is this happening:
$ python3
Python 3.1.2 (release31-maint, Dec 9 2011, 20:50:50)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import argparse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named argparse
I installed python3 precisely because I wanted to use argparse, which was new in 2.7, and the default version on Ubuntu Server 10.04 is 2.6.
Another thing I've noticed: Mint 10 comes with python 2.6.6, which does include argparse, and the exact version that ships with ubuntu-server 10.04 is 2.6.5 which does not have argparse. Also, I've noticed that on my Ubuntu 12.04 machine python3 is 3.2.3 and this does come with argparse. Why would this module not be included with 3.1.x???
Although argparse only made it into the standard lib on Python 2.7 and Python 3.2, for older/other versions you can still get it from pypi.
Keep in mind though that this version may not include all the updates that happened since the merge of argparse to the standard lib (as it's explained on the original project's webpage).