cx_Freeze does not seem to import nor install using pip - pygame

When I try to import CX_Freeze I get this error:
But I tried to compile a pygame script I made anyways and I got this error:
If you can help me that would be great.
Thank you

try the below command to see you installed packages:
pip list
If you do not see cx_Freeze displayed in the list try to install by this command:
pip install --upgrade cx_Freeze

As the error states, you need to install or update Microsoft Visual C++ to 14.0 or greater. If you don't want to, try other modules such as py2exe
See also:
https://www.pygame.org/wiki/Pygame2exe

Related

mysqlclient installtion error on python3.6 in venv in unix20.0

Link to open the issue image
When I tried to install mysqlclient using pip in unix inside virtualenv it showed me MySQLdb/_mysql.c:46:10: fatal error: Python.h: No such file or directory. please help me with your suggestions. Thank you
had this exact error today. Turns out Python 3.10 hadn't been installed [it was downloaded and made, but sudo make install wasn't done]. Idk if you're active or if this is relevant since it's been a long time, but give it a shot.

Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3

I've trawled the forums but cannot find an answer or even any documentation on this. Trying to re-create a site like www.testandtrack.io
On running the command:
python manage.py inspectdb
I get the error:
mysqlclient 1.3.13 or newer is required; you have 0.9.3
I have tried all the suggested fixes including:
-upgrading pip
-installing a different wheel (32 bit instead of 64), namely mysqlclient-1.4.2-cp37-cp37m-win32.whl with the command pip install mysqlclient-1.4.2-cp37-cp37m-win32.whl (this works fine without an error but doesn't do the job required!)
My objective is to simply connect a legacy mysql database (running inside of XAMPP and myphpadmin) to Django. I've followed the documentation which misses out the need to install mysqlclient, and have got stuck at this point.
I guess your project uses pymysql instead of mysqlclient.
You can try to search the following code snippet in your project. If you find it, please try the following methods to fix this problem:
import pymysql
pymysql.install_as_MySQLdb()
Insert a line of code between these two to make it look like this:
import pymysql
pymysql.version_info = (1, 3, 13, "final", 0)
pymysql.install_as_MySQLdb()
Then try to start your project.
Why do I know you are using pymysql? Because 0.9.3 is just the latest version of pymysql.
Why use pymysql instead of mysqlclient for the project? Because it is easier to install. pymysql does not depend on system libraries, while mysqlclient relies on a series of system libraries such as libmysqlclient-dev.
Why is mysqlclient difficult to install and Django still uses it by default? Because mysqlclient is faster and performs better. So if your project has high performance requirements, I suggest you remove the compatible code above and install mysqlclient in your project. If you need help during the installation of mysqlclient, please refer to this link: How to install Python MySQLdb module using pip?, and ensure libssl-dev has been installed before pip install mysqlclient.
This is how I fixed it.
Go to your django/db/backends/mysql installation dir.
Check your path in the error message.
I'm using pipenv so my path is:
/home/username/.local/share/virtualenvs/project-env/lib/python3.7/site-packages/django/db/backends/mysql
If you use traditional env your path would be:
<env_directory_name>/Lib/site-packages/django/db/base.py
Open file base.py and search for:
version = Database.version_info
Put a pass inside if and comment line:
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required;
you have %s.' % Database.version)
Like this.
if version < (1, 3, 13):
pass
'''
raise ImproperlyConfigured(
'mysqlclient 1.3.13 or newer is required; you have %s.'
% Database.__version__
)
'''
Save, close this file and open operations.py.
Search for:
query = query.decode(errors='replace')
and change decode to encode
query = query.encode(errors='replace')
Now, try to run the server.
#edit
Until this answer, I found no other way to solve it. Today there are better ways to deal with this problem. This answer has a better approach.
I have had the same issue as lower version of mysqlclient was installed due to pymysql.
OS: Linux Mint 19.1
Python: 3.6.8
Django: 2.2.2
Uninstall mysqlclient: pip3 uninstall mysqlclient
Uninstall pymysql: pip3 uninstall pymysql
Install mysqlclient: pip3 install mysqlclient
this problem occurs when you create Django project in pycharm by default settings.
It's caused by the default version of django is 2.2.6, so just downgrade the django version to 2.1.7, and error in the terminal is gone.
pip install Django==2.1.7
that's all!
Instead of edit internal configuration, try to upgrade the version of mysqlclient
pip3 install -U mysqlclient
The following solution works in Django 3.2.3 to get rid of the 'mysqlclient 1.3.13 or newer is required; you have 0.9.3' problem:
1) pip uninstall mysqlclient # remove old version
2) pip install mysqlclient==1.3.13
3) comment or remove the old workaround in __init__.py of the main app.
# workaround django.core.exceptions.ImproperlyConfigured:
#Error loading MySQLdb module.
#Did you install mysqlclient?
#import pymysql
#pymysql.install_as_MySQLdb()
Install wheel:
pip install wheel
Download file that you want from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
Move to your Downloads directory (I guess it'll be cd Downloads)
Install downloaded file with: pip install <file name>
WARNING!! You CANT edit name of downloaded .whl file. It contains some information what is required to install.
It worked fine with me just open settings.py and include
import pymysql
pymysql.version_info = (1, 4, 6, 'final', 0)
pymysql.install_as_MySQLdb()
I had a similar issue, I was getting
"django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 1.3.12."
So I went to the C:\Users\username\Envs\env\Lib\site-packages\django\db\backends\mysql, opened base.py and changed that line...
if version < (1, 3, 13):
to...
if version < (1, 3, 10):
which is a version lesser than mine and it worked.
If it's not critical for you, as a variant, just downgrade your django framework from 2.2.2(for example) to 2.1.
I was finding a solution for this issue from a long time. I was using Ubuntu 18.04 and found this solution to be useful for python version 3.7.5
Step 1. Install libpython3.7-dev via sudo apt-get install
> sudo apt-get install libpython3.7-dev
Step 2: Install mysqlclient
> python3 -m pip install mysqlclient==1.4.6
If you are working with Django on ubuntu, i will suggest you do the following to resolve the issue than editing django specific configuration files
run the following commands in the terminal
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
pip install mysqlclient
Maybe your Django project uses pymysql, instead of upgrading mysqlclient, just do
pip install pymysql -U
This works for me ! :D
There are the same issue on github. Solution that perfectly fits for me is here.
I just quote an author:
I first pip uninstall pymysql (as it seems it doesn't work anymore)
Then I've used pip install mysqlclient
Last, I checked all my "pymysql" imports and deleted them.
Be sure to go and hit a like button on the comment in the link
Go to your virtual environment directory like mine:
C:\Users\user\.virtualenvs\RPA-Orchestrator-Backend-GwIL98hN\Lib\site-packages\django\db\backends\mysql\base.py
Here you might edit one line to avoid your error in the base.py file,
version = Database.version_info
if version < (0, 9, 3):
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
Then your problem might solve.

python 3.3 and pip tool installation

Pip3 installation and Python 3.3 on windows vista
I have been using python 3.2 for a short time and I wanted to install pygame and other other packages. At that point I realised that I have to install pip tool as a package manager. In short, in the process, I removed python 3.2 and installed properly python 3.3 and encountered the following problems:
From python 3.3 interactive interpreter:
when I do: pip --version I get:
nameerror pip not defined
When I go Python get-pip.py I get
syntaxerror and the get is in red
sudo python 3.3 setup.py install gives error as well
But I was able to download the get-pip.py script and this script is inside my download manager. Again,there is no pip tool when I checked my python3.3 script directory.
Thank you in advance for your attention
Usually get-pip.py runs.If nothing is working, try the wheel file. Download the .whl file and run:
python.exe pip-9.0.1-py2.py3-none-any.whl
Hope this helps.

Installing Pygame without whl files [duplicate]

Currently unable to install Pygame via pip:
pip install pygame
Getting this message:
Concerned by it being termed an EOF error, is this an error in the module itself?
There's dev versions available as of now. Get them via
pip install pygame==2.0.0.dev6
Pygame is not compatible with Python 3.8 at the moment. I would recommend you to downgrade back to 3.7 and installing with pip there.
pip is doesn't have pygame up.
But there is a alternative that worked for me. https://www.pygame.org/wiki/CompileWindows
Read and follow the steps correctly and it should install.
you also need to update your code to pygame 2.0.0 code because it's only for 3.8
BTW you have to follow the SDL2 instructions since pygame 2.0.0 uses that.
the above commands worked for me today 3-15-20 with Python-3-8-0 on Linux Mint 19
to get IDLE to recognize pygame.
sudo pip3 install pygame==2.0.0.dev6
I also had to update pip first with
sudo pip3 install --upgrade pip
Pygame requires visual studio C++ build tools to install. Ensure you have these downloaded from here.
Open power shell window and make sure your internet is on
Then type the following command
pip install pygame
It will automatically download it for you and also install it
Again make sure your internet is on
I have python 3.8.2 and it worked on my pc

How to access MySQL from python

I've always used Xampp for db/ server purposes. I'm trying to use the same with my Python project but cannot seem to get it to work.
Error from Python Shell
import MySQLdb
ImportError: No module named 'MySQLdb'
I've been all around but nothing seems to work. I'm on windows 7, Python 3.3.
Please someone advise. Links that would resolve this quick will be greatly appreciated.
Update:
Please note that it seems MySQL-python does not support python3
From this discussion : https://groups.google.com/forum/#!topic/django-developers/8r_RVmUe5ys
Here is some connectors that can be used for mysql in Python 3.x:
https://github.com/davispuh/MySQL-for-Python-3 / https://github.com/clelland/MySQL-for-Python-3
http://www.pymysql.org/
https://github.com/farcepest/moist
https://pypi.python.org/pypi/mysql-connector-python/1.0.9
pip install MySQL-python
Run this in your Windows console or Linux terminal, and this problem should disappear.