Is tkinter renamed in Python 3.9.0b3? - python-3.x

I just upgraded to python 3.9 (Earlier I had python 3.8.2)
I was working on a project where I had to use tkinter module.
Everything worked fine in Python3.8.2
But after upgrading to Python3.9 , I get this error :
The error is :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/tkinter/__init__.py", line 37, in
<module>
import _tkinter # If this fails your Python may not be configured for
Tk
ModuleNotFoundError: No module named '_tkinter'
So anyone knows how to fix this ?
P.S :
I have tried using
sudo apt install python3-tk
It only gives this message :
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-tk is already the newest version (3.8.2-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Edit :
I found 2 pip installed on my system namely : pip3 and pip3.9 (I don't know how)
One is familiar pre existing pip3
When I do pip3 list
Package Version
------------------------ --------------------
aiohttp 3.6.2
apturl 0.5.2
astroid 2.4.2
async-timeout 3.0.1
attrs 20.2.0
autopep8 1.5.4
#(And many more...)
But when I do pip3.9 list , I get only 2 modules installed:
Package Version
---------- -------
pip 20.2.3
setuptools 41.2.0

Okay , Got it what was wrong (Thanks to #acw1668 ). I installed python 3.9 from the source without having dependencies (tk-dev and tcl-dev)
So the first thing I did was uninstalling Python3.9
Then reinstalled it using this method (From deadsnakes ppa)
Then in terminal , run sudo apt install python3.9-tk
Now everything works fine.
Thanks to #Noah-J-Standerson for suggesting this method

Related

Rpy2 import rpy2.robjects as robjects fails

I've installed rpy2 through pip install rpy2. After this in a Jupyter notebook the import works fine:
import rpy2
print(rpy2.__version__)
which returns 3.1.0.
However when I type this import rpy2.robjects as robjects, I get the following error:
ValueError: The system "%s" is not supported.
Does someone know where this error comes from and how to solve it?
I had exactly the same problem.
I uninstalled the package and reinstalled it with conda (as I use Jupyter notebook through Anaconda):
conda install rpy2
Doing this it worked just fine.
The version installed was 2.9.4. There may be an issue with the version 3.1.0 I believe.
I have a similar problem. I had previously installed rpy2 2.9.5 withpip3 install rpy2 and it worked fine. However, today I tried updating it with pip3 install --upgrade rpy2 and got the following error:
Collecting rpy2
Using cached https://files.pythonhosted.org/packages/62/bc/d43df0d9e96a38985a97d1cbdb5722e10cd8fa0da45686972f0b8fd18a67/rpy2-3.2.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-irk23ljv/rpy2/setup.py", line 21, in <module>
from rpy2 import situation
File "/tmp/pip-build-irk23ljv/rpy2/rpy2/situation.py", line 98
raise ValueError(f'The system {system} is currently not supported.')
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-irk23ljv/rpy2/
I can't just stick to the older version because what I'm actually trying to do is to install another Python package that has rpy2 listed as a dependency. The install fails with the same error message.
Any update on the subject?
Edit
It looks like this might be a compatibility issue with Python 3.5 -- see https://bitbucket.org/rpy2/rpy2/issues/580/installing-rpy2-on-travis-with-pip. I've just opened an issue here: https://github.com/rpy2/rpy2/issues/356

zlib dependency for Pillow fails on ubuntu 18.04 despite required library installed

I would like to install the Pillow package on an Ubuntu 18.04 VPS running Python 3.7. I first created a virtual environment --
python -m venv /path/to/env
source /path/to/env/bin/activate
from there i tried installing Pillow by running pip install Pillow but the following exception happens:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-0c7eruo4/Pillow/setup.py", line 806, in <module>
raise RequiredDependencyException(msg)
__main__.RequiredDependencyException:
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
According to this answer the package libjpeg8-dev needs to be installed, but Ubuntu's telling me it's already been installed, so I don't know what's going on. (I also verified the non-dev version libjpeg8 was installed, to be safe) I haven't encountered this many errors when simply setting up a Python development environment before -- can someone advise?

How to install and use PyQt5 in Linux

In Ubuntu I installed PyQt via pip
pip3 install PyQt5
However, my script still says:
Traceback (most recent call last):
File "/media/storage/Python/my_app.py", line 11, in
from mainwindow import * File "/media/storage/Python/mainwindow.py", line 4, in
from PyQt5 import QtCore, QtWidgets
ImportError: No module named PyQt5
Then I tried from terminal:
sudo apt-get install python3-pyqt5
and got that it is installed:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pyqt5 is already the newest version (5.7+dfsg-5).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
How to convince PyCharm 2017.1 to use PyQt5? I just realized it works if I run it from terminal:
python3 my_script.py
The problem here is that you need to set the correct interpreter in PyCharm.
To do this you can go in
Settings -> Project -> Project Interpreter
and here choose the correct one in the select at the top of the window.
After this you should see the PyQt in the list below. Then click on Apply and try to run again your script.

pip3 works with python3.2 but won't work with python3.3

I have created a virtual environment for python3
virtualenv -p /usr/bin/python3 myenv
Everything works ok and pip installs python3 packages. Then I need to upgrade my python3.2 to python3.3. I am using ubuntu 12.04, so I need to do what Luper Rouch suggests here through ppa
I copy /usr/bin/python3.3 into myenv/bin/python3, thus (inside myenv):
python --version
returns Python 3.3.5. But then pip stops working failing with
pip install urllib3
Traceback (most recent call last):
File "mypathtoevn/bin/pip", line 7, in <module>
from pip import main
ImportError: No module named 'pip'
Then I understand that I have to use
pip3.3 install <package_name>
but I can't find any other pip*.* version either globally or inside virtualenv in my system.
How can I get pip3.3 or any other pip version?
Thanks
The ppa you have installed does not contain pip. The python package installer is itself installed with easy_install. On the question you linked to follow the later parts of this answer
Basically, calling
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
should be sufficient. You should use the easy_install command of your Python3.3 install.
Check with
which python
where your python comes from, and search for easy_install in that path. In your case you know where it resides: Your virtualenv.

No errors installing MYSQLdb, but I can't import

I'm running Linux Mint 13 and Python 2.7.3 and I'm trying to install mysqldb, but can't import it. I run:
sudo apt-get install build-essential python-dev libmysqlclient-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version.
libmysqlclient-dev is already the newest version.
python-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 465 not upgraded.
sudo pip install MySQL-python
Requirement already satisfied (use --upgrade to upgrade): MySQL-python in /usr/local/lib/python2.7/dist-packages
Cleaning up...
Within the python command line, I run:
import MYSQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MYSQLdb
I've also tried:
sudo apt-get install python-mysqldb
Any ideas?
It should be import MySQLdb, not import MYSQLdb. Case matters.

Resources