python3.4.4 import tkinter wrong - python

I installed tkinter from yum,but I can only use it in Python2.
This is in Python3:
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/tkinter/__init__.py", line 38, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
and I can use "import Tkinter" in python2.
But how i can use it in Python3, Thanks.

Install python3:
sudo apt-get update
sudo apt-get install python3.5
If you have already done that, ge the setuptools:
sudo apt-get install python3-setuptools
sudo apt-get upgrade python3-setuptools
After which install tkinter:
sudo -H pip3 install tkinter

Related

ImportError: No module named gtk

I have a PC running Ubuntu 17.10. I want to runn a python script that uses gtk. HoweverI get the following error:
Traceback (most recent call last):
File "/usr/local/bin/selectvm.py", line 3, in <module>
import gtk
ImportError: No module named gtk
I have tried already many things like:
sudo apt install python-gtk2
sudo apt install python-gtk2-dev
but none of them works. APT says they are already installed.
Try:
sudo apt-get install python-gtk2
These are the python bindings for GTK.
Graphic package nessesary to build the software-center UI.
Or:
sudo apt-get install afnix
credits

Python ImportError: No module named utils

I am trying to run my python script in Debian but I keep getting the following error:
traceback (most recent call last):
File "gluon/contrib/websocket_messaging.py", Line 96, in <module>
import gluon.utils
ImportError: No module named utils
I've tried:
pip install gluon
Still didn't work. I also tried:
sudo apt-get update
sudo apt-get install python-gluon
but got
Unable to locate package python-gluon
Any help would be appreciated thank you
sudo apt-get update
sudo apt-get install python3-gluon
OR
pip3 install gluon

Python3 pip3 install broken on Ubuntu

I installed python3 and pip3 successfully on my Ubuntu16.04, but pip3 install is broken. How can I fix this problem? The error info of pip3 install is as follows:
# pip3 install xlwt
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.requests'
Output of "which pip3" and "pip3 --version":
# which pip3
/usr/bin/pip3
# pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.requests'
p.s. Python2 pip runs successfully.
Output of "which pip" and "pip --version":
# which pip
/usr/bin/pip
# pip --version
pip 1.5.4 from /usr/local/lib/python2.7/dist-packages/pip-1.5.4-py2.7.egg (python 2.7)
And python and python3 installation information:
# which python
/usr/bin/python
# which python3
/usr/bin/python3
# python -V
Python 2.7.14
# python3 -V
Python 3.6.3
Any solution or clue will be appreciated! Thank you!
Here, trying this method: https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py
# sudo python3 get-pip.py
This has happened to me multiple times before. A lot of the time, pip3 has issues installing with python3 by default, so try uninstalling and reinstalling pip3. Hope this works.
sudo apt-get remove python3-pip; sudo apt-get install python3-pip
EDIT:
After doing some scouting about pip.vendor.requests, it seems like this is a very common error relating to SSL problems. If this line gives you errors in python (import ssl), some solutions can be found here:
https://github.com/pypa/pip/issues/2345.
This worked for me.
First remove your python3-pip:
sudo apt remove python3-pip
Then do this:
sudo apt install --purge python3-setuptools
And finally:
sudo apt install python3-pip
python-pip is in the universe repositories, therefore use the steps below to solve Python3 pip3 broken problem on Ubuntu. Also works for Ubuntu available from official store in windows 10 for WSL (windows subsystem for linux):
sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get -y install python3-pip
I got help from here - [https://askubuntu.com/a/672836/876942]. Following these steps installs python 2. But then I installed python 3 using [sudo apt-get -y install python3-pip] in last step.

python3.4 pip ImportError: No Module named 'pkg_resources'

pip is not working in my python3.4
$ pip install django
Traceback (most recent call last):
File "usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named 'pkg_resources'
$ pip
Traceback (most recent call last):
File "usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named 'pkg_resources'
How do I fix this? What's the problem? Thanks
i just ran into the same error, here is what i've done to fix it:
sudo apt-get remove --purge python-pkg-resources
sudo apt-get install ubuntu-desktop
Try >sudo pip install django< I think that ought to do it
well then I suspect your pip is messed up so try
sudo apt-get install --reinstall python-pkg-resources
however if you are using Python 3 you may need to adjust to insure that you get the Python 3 environment set up rather than the P2 default
see here for more on that
How to use pip with Python 3.x alongside Python 2.x

ImportError: The _imaging C module is not installed? PIL Python3

root#syscomp1:~# cd Pillow-master
root#syscomp1:~/Pillow-master# python3 selftest.py
Traceback (most recent call last):
File "selftest.py", line 8, in <module>
from PIL import Image
File "./PIL/Image.py", line 155, in <module>
if hasattr(core, 'DEFAULT_STRATEGY'):
File "./PIL/Image.py", line 39, in __getattr__
raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed
root#syscomp1:~/Pillow-master#
this is the step before i install PIL
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade pip
sudo pip install --upgrade virtualenv
sudo aptitude install python3-setuptools
sudo easy_install3 pip
sudo apt-get install python3-dev
download the Pillow-master.zip
wget https://github.com/python-imaging/Pillow/archive/master.zip
go to downloaded directory and,
sudo unzip master.zip
sudo apt-get install libjpeg62-dev //must install this
sudo apt-get install zlib1g-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install liblcms1-dev
python3 setup.py build_ext -i
but error with The _imaging C module is not installed why?
Looks like a Python 2 print statement in setup.py:
Downloading from URL http://effbot.org/media/downloads/PIL-1.1.7.tar.gz (from http://effbot.org/downloads/)
Running setup.py egg_info for package pil
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "<pyenv>/build/pil/setup.py", line 182
print "--- using Tcl/Tk libraries at", TCL_ROOT

Categories

Resources