Unable to install python-docx on WIndows - python-docx

I did C:\ Python27\mystuff\python-docx-0.8.5\pip install python-docx
Getting errors as shown below

For your first query:
Open cmd as admin.
Goto C:\Python27\Scripts
Type: pip install python-docx
This should do the trick.
For your second query(pip problems)
1. I would advice you to reinstall your pip: pip install --upgrade --force-reinstall (After going to above specified folder)
Note: This will not affect your existing packages.

Try installing python-docx using the pip tool.
https://pip.pypa.io/en/latest/installing/
First download pip from the above link and extract into C:\pip
Then try installing python docx from the below link using pip install python-docx from c:\pip directory.
http://python-docx.readthedocs.org/en/latest/user/install.html
Hope it helps.

Download the python-docx package from this link:
https://pypi.python.org/pypi/python-docx
Then go to the Download folder in cmd: pip install package-name
If your inside proxy, remember to set it.

Related

cx_Freeze does not seem to import nor install using pip

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

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.

Failed building wheel for mysql-python

I want to run a Django application in PyCharm which works on MySQL DB.
I am unable to connect my program to the database.
When I am trying to install MySQLclient or MySQL-python I am getting the error:
Failed building wheel for MySQLclient
Please help me out in connecting my Django program with MySQL database.
Edit
Please try installing the .whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/. This works every time. Just type pip install MySQL_python‑1.2.5‑cp27‑none‑win32.whl in the terminal.
Original Answer
I had the same issue. You might find these steps helpful.
Make sure you are in an activated virtualenv when you are installing anything through pip.
Before you install anything, type pip list in the terminal to see what you have installed in the virtualenv. It should have wheel, setuptools and pip.
This is the part that helped me, type pip install mysqlclient==1.3.9 or whatever version you want to install. This needs to happen before you install django.
Hopefully, it works and you can go ahead and install Django.
If these steps didn't work out for you, try installing MySQL-Python through the executable file here https://pypi.python.org/pypi/MySQL-python/1.2.5.
But this will only install mysql-python for you in the system. You can try pip list outside virtualenv to see if mysql-python is installed. If it is installed, then you have update this post so we can figure out a solution.
In the meantime some other fixes are:
Can't install mysql-python (newer versions) in Windows
Install Visual C++ for Python and add the bin folder to the PATH environment variable.
Make sure the mysql service is running in the background or is installed in your system by running mysql commands through the terminal.
Sometimes, two different instances of mysql service might cause this error i.e. if you have installed mysql server or any other product multiple times in the past, you might have to get rid of the ports the past services used. In this case, do a fresh installation of mysql server and add the ~\bin path to the PATH environment variable.
I had the same problem. I then uninstalled my python. Downloaded the python 3.6.5.
then used a command from
Python 3.7, Failed building wheel for MySql-Python
the command is pip install mysqlclient==1.3.12
In case you are using sqlalchemy(which implicitly uses mysql-python) to connect to a MySQL database, updating it using pip install sqlalchemy --upgrade might do the trick and while creating a connection using an engine the syntax should be:
from sqlalchemy import create_engine
HOST = "your_host_name.host.com"
USER = "your_username"
PASSCODE = "your_passcode"
DATABASE = "name_of_database"
engine = create_engine(f'mysql+mysqldb://{USER}:{PASSCODE}#{HOST}/{DATABASE}')
I found a solution to install mysqlclient on Windows 10 64 bit, Django version 3.10.0
Download preferred mysqlclient wheel for your OS/bit size. here :
https://pypi.tuna.tsinghua.edu.cn/simple/mysqlclient/
Point to the directory such as C:\Users\hp\Desktop\storefront\store from your prompt or terminal
install using pip i.e: C:\Users\hp\Desktop\storefront\store > pip install mysqlclient-2.1.0-cp310-cp310-win_amd64.whl
I hope this would help.I am running Python3.7 on windows 7 (32-bit). I had the same issue and tried using PIP commands from windows CLI. Although, my pip installation was successful but I was not able to add MYSQL or MYSQL-Connector-Python from Pycharm GUI. I used Pycharm Terminal for Below packages and was able to connect to MYSQL database.
Example:
(PTPT) C:\Windows\System32>pip3 install mysql-connector-python==8.0.29
Collecting mysql-connector-python==8.0.29
Downloading https://files.pythonhosted.org/packages/32/cd/1581bfe8f5ad7fd2aecdc499f0387227ad7912419384f9393b6205a764da/mysql_connector_python-8.0.29-py2.py3-none-any.whl (342kB)
|████████████████████████████████| 348kB 409kB/s
Requirement already satisfied: protobuf>=3.0.0 in c:\users\maghy\ptpt\lib\site-packages (from mysql-connector-python==8.0.29) (3.20.1)
Installing collected packages: mysql-connector-python
Found existing installation: mysql-connector-python 8.0.30
Uninstalling mysql-connector-python-8.0.30:
Successfully uninstalled mysql-connector-python-8.0.30
Successfully installed mysql-connector-python-8.0.29
WARNING: You are using pip version 19.3.1; however, version 22.2.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
pip install C:\Users\USER_NAME\Downloads\mysqlclient-1.4.6-cp37-cp37m-win32.whl
PYCHARM MYSQL PACKAGE

libmysqlclient15-dev on macs?

Does OSX need an install of libmysqlclient15-dev? I'm trying to compile a gem that is failing and a lot of sources says to install "libmysqlclient15-dev" but I only see this for Linux, not OSX. Am I missing something here?
brew install mysql
fixed this for me
I know this is old, but google got me here. So let's say the solution in 2018 for python3 on OSX.
brew install mysql-client
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
pip install mysqlclient
I just had the same problem and only got a partial working solution.
Here are the steps I made to make it work:
brew install mysql-client
brew install mysql-connector-c
IF YOU HAVE ZSH:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
ELSE:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
Now for the installation itself:
LDFLAGS=-L< your openssl lib folder location > pip install mysqlclient==< version >
for example:
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient==1.3.12
If you are using the mysql dmg file to install mysql you will need to edit your ~/.bash_profile and include this:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
brew install mysql
then
arch -x86_64 gem install mysql2 -v 0.5.3 -- --srcdir=/usr/local/mysql/include
Afterwards I was able to run bundle install.
Copied from Bragadeesh Jegannathan's blog post
Yes you will need to install this. For example if you are trying to install the mysql gem you will need the headers for the mysql library. This is because some gems need to compile native extensions, so they need the header files for any 3rd party libraries that the extensions uses.
On Mac OS X I recommend using MacPorts to manage the installation of these libraries/headers.
Those instructions are for Debian type Linuxes. The closest thing to Debian for OS X is Fink. After getting that installed and set up, you can say fink install mysql-unified-dev to get essentially the same thing as asking for libmysqlclient15-dev on a Debian or Ubuntu type system.
Beware that Fink installs its packages in /sw, and not all build scripts know to look there for libraries and headers. You might have to give custom build options to get it to figure this out.
A path that may be more successful is to simply download the MySQL 5.0 package for Mac OS X. That should include the same development files as libmysqlclient15-dev, and as a bonus will put them in places more likely to be found by your gem.
(Why 5.0, by the way? Because that's what corresponds to ABI version 15, which your package apparently requires. Maybe it will in fact work with 5.1, or 5.4, or 6.0, but that would be a risk you'd have to decide to take on your own.)