Getting error while trying "pip install python-docx" in pycharm terminal - python-docx

New to python and just trying pip install python-docx and getting this message:
Command "C:\Users\samue\PycharmProjects\testings\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file
__='C:\Users\samue\AppData\Local\Temp\pip-install-_4bceyq4\lxml\setup.py';f=getattr(tokenize, 'open', open
)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record
C:\Users\samue\AppData\Local\Temp\pip-record-pg5bpdaa\install-record.txt --single-version-externally-managed --com
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\bin\Hos
tX86\x86\cl.exe' failed with exit status 2
----------------------------------------
Command "C:\Users\samue\PycharmProjects\testings\venv\Scripts\python.exe -u -c "import setuptools, tokenize;file='C:\Users
\samue\AppData\Local\Temp\pip-install-_4bceyq4\lxml\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().re
place('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\samue\AppData\Local\Temp\pip-reco
rd-pg5bpdaa\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\samue\PycharmProjects\te
stings\venv\include\site\python3.8\lxml" failed with error code 1 in C:\Users\samue\AppData\Local\Temp\pip-install-_4bceyq4\lxml
\

When you install with pip you use the command pip and not python.
To see whether pip is correctly installed type:
pip help
See the following page for how to install and configure pip on Windows:
https://phoenixnap.com/kb/install-pip-windows
Your error output shows a problem with lxml. Looking into it I have found the page pip install lxml error which suggests the following solution:
sudo apt-get install --reinstall python-dev libpython2.7-dev.

Related

how to install pyaudio 083546

I got an error while installing pyaudio
I have downloaden portaudio but i am not sure where to put it. I am trying to create a SpeechRecognition program that won't work without speechrecognition.
The following error occurs:
C:\Users\lenovo>pip install pyaudio
Collecting pyaudio
Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\lenovo\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\lenovo\\AppData\\Local\\Temp\\pip-install-w_ldd4wb\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\lenovo\\AppData\\Local\\Temp\\pip-install-w_ldd4wb\\pyaudio\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\lenovo\AppData\Local\Temp\pip-record-ckrughg6\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\lenovo\AppData\Local\Temp\pip-install-w_ldd4wb\pyaudio\
Complete output (9 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
copying src\pyaudio.py -> build\lib.win-amd64-3.7
running build_ext
building '_portaudio' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\lenovo\appdata\local\programs\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\lenovo\\AppData\\Local\\Temp\\pip-install-w_ldd4wb\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\lenovo\\AppData\\Local\\Temp\\pip-install-w_ldd4wb\\pyaudio\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\lenovo\AppData\Local\Temp\pip-record-ckrughg6\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
edit:
I found a solution for windows!
go to https://www.lfd.uci.edu/~gohlke/pythonlibs/
and then press
ctrl + f
to find "pyaudio"
you will get
go and find something like this
PyAudio: bindings for the PortAudio library. Includes ASIO, DS, WMME, WASAPI, WDMKS support. PyAudio‑0.2.11‑cp310‑cp310‑win_amd64.whl PyAudio‑0.2.11‑cp310‑cp310‑win32.whl PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl PyAudio‑0.2.11‑cp39‑cp39‑win32.whl PyAudio‑0.2.11‑cp38‑cp38‑win_amd64.whl PyAudio‑0.2.11‑cp38‑cp38‑win32.whl PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl PyAudio‑0.2.11‑cp37‑cp37m‑win32.whl PyAudio‑0.2.11‑cp36‑cp36m‑win_amd64.whl PyAudio‑0.2.11‑cp36‑cp36m‑win32.whl PyAudio‑0.2.11‑cp35‑cp35m‑win_amd64.whl PyAudio‑0.2.11‑cp35‑cp35m‑win32.whl PyAudio‑0.2.11‑cp34‑cp34m‑win_amd64.whl PyAudio‑0.2.11‑cp34‑cp34m‑win32.whl PyAudio‑0.2.11‑cp27‑cp27m‑win_amd64.whl PyAudio‑0.2.11‑cp27‑cp27m‑win32.whl
now download the one which is of same version of your python and OS
now after downloading open your cmd/terminal
go to its path and then
pip install <Pyaudio-blablabla> <= your file name
now it will be installed!
Enjoy!
The last line of the stacktrace contains the error:
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
This error can be fixed by installing the suggested tools from:
https://visualstudio.microsoft.com/visual-cpp-build-tools/

Can't Install MySQL-Connector Library

I was using the mysql-connector 2.1.8 for a while and out of a sudden, it was no longer available.
Could not find a version that satisfies the requirement mysql-connector==2.1.8 (from versions: 2.2.8)
I tried installing some newer versions, like 2.2.5. Which literally worked once and then didn't on a server.
And the latest version 2.2.8 gives an error like this:
Collecting mysql-connector==2.2.8
Using cached https://files.pythonhosted.org/packages/8e/78/049f747325ce0154263cd1b10fe7ea9ddb17e839111c6f8f824d5964cfb5/mysql-connector-2.2.8.tar.gz
Installing collected packages: mysql-connector
Running setup.py install for mysql-connector ... error
Complete output from command /home/liudas/PycharmProjects/eneba_what_place/venv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-7rlbpvfn/mysql-connector/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-kbw8r138/install-record.txt --single-version-externally-managed --compile --install-headers /home/liudas/PycharmProjects/eneba_what_place/venv/include/site/python3.6/mysql-connector:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: option --single-version-externally-managed not recognized
pip install -U setuptools wheel
Newer package version might require newer features of setuptools or wheel, so it's what causes --single-version-externally-managed not recognized
A good thing to keep such core packages up to date, plus they are almost always backwards compatible.

Unable to install Python-igraph using pip in ubuntu

I got following error when I am trying to install python-igraph using sudo pip install python-igraph
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ZHOdbM/python-igraph/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-MGaN23-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ZHOdbM/python-igraph/
I also try to install C core using the link given in the answer UnicodeDecodeError when installing python-igraph
I would suggest you to use conda and the following command :
conda install -c conda-forge python-igraph
https://anaconda.org/conda-forge/python-igraph

Mac OS Sierra virtualenv (python 2.7) pip install mysqlclient error

On Mac OS Sierra, created virtualenv using python2.7 and trying to install mysqlclient to use Django w/ MySQL. I installed MySQL 5.6 via homebrew. Running "pip install mysqlclient" gives these errors:
Running setup.py bdist_wheel for mysqlclient ... error
...
13 warnings generated.
cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql56/5.6.32/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
Failed building wheel for mysqlclient
Command "...env2.7/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-xVuIu1-record/install-record.txt --single-version-externally-managed --compile --install-headers .../env2.7/include/site/python2.7/mysqlclient" failed with error code 1 in /private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/
Any help would be greatly appreciated.
The answer was installing dev tools using:
xcode-select --install
In my case I needed to do two steps:
xcode-select --install
as #howevilweare says AND also pip install with the brew installed openssl using an env command:
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient

error: command 'x86_64-linux-gnu-gcc' when installing mysqlclient

I installed django 1.8.5 in virtualenv and using python 3.4.3
the worked displayed the it works page when using sqlite
I wanted to use mysql and I'm trying to install mysqlclient using
pip install mysqlclient
and I'm getting the following message
----------------------------------------
Failed building wheel for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient
Complete output from command /home/sasidhar/django/env/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-5lj39q67/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-da2_35zs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/sasidhar/django/env/include/site/python3.4/mysqlclient:
running install
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.4/MySQLdb
running build_ext
building '_mysql' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,6,'final',1) -D__version__=1.3.6 -I/usr/include/mysql -I/usr/include/python3.4m -I/home/sasidhar/django/env/include/python3.4m -c _mysql.c -o build/temp.linux-x86_64-3.4/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
_mysql.c:40:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/sasidhar/django/env/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-5lj39q67/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-da2_35zs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/sasidhar/django/env/include/site/python3.4/mysqlclient" failed with error code 1 in /tmp/pip-build-5lj39q67/mysqlclient
I did try installing libraries suggested in error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
and still the problem persists
please help me solve this problem
Thanks guys!!
You need to install python-dev:
sudo apt-get install python-dev
And, since you are using python3:
sudo apt-get install python3-dev
This command should help you.
If you are using mac os you might try:
brew update && brew rm python3 && brew install python3
You need to brew has been installed already, otherwise you can install it. It is very useful for getting packages in Mac OS. http://brew.sh/
For Ubuntu you also need to install build-essential
sudo apt-get install build-essential
For those using different versions, such as Python 3.5, 3.6 or 3.7 I found this:
Part I
For Python 2.x use:
$ sudo apt-get install python-dev
For Python 2.7 use:
$ sudo apt-get install libffi-dev
For Python 3.x use:
$ sudo apt-get install python3-dev
For Python 3.4 use:
$ sudo apt-get install python3.4-dev
For Python 3.7 use:
$ sudo apt-get install python3.7-dev
Part II
If this still doesn't help, others have pointed out to install
$ sudo apt-get install build-essential
and finally
$ sudo apt-get install libssl-dev
But the last two didn't help me personally. Just in case, hope it helps you.
For those using python3.5:
apt-get install python3.5-dev
wget https://bootstrap.pypa.io/get-pip.py
python3.5 get-pip.py
pip3.5 install mysqlclient
Tried all of the above suggestions and a few found elsewhere and nothing worked. In the end the solution was simple enough (courtesy of ignacionf on GitHub):
pip install git+https://github.com/PyMySQL/mysqlclient-python.git