Can't install python-docx using pip - python-3.x

I am very new to python and programming in generall. I am following a tutorial and tried to install python-docx using pip in the cmd, but it doesn't work.
Those are the errors i see:
DEPRECATION: lxml is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
Running setup.py install for lxml ... error
error: subprocess-exited-with-error
and
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> lxml
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Can somebody help me with that problems in a way that even a newcomer like me understands it ?
I tried it with >pip install python-docx and >pip install python-docx==0.8.11 in the cmd.

I have had the same error. Check if you have
Microsoft Visual C++ 14.0 or greater. You can download it here. https://visualstudio.microsoft.com/visual-cpp-build-tools/
That has solved the problem for me

I found a solution. It worked after installing a manual build windows x64 wheel for python 3.11. See github_lxml/lxml#356

Related

Installing dlib in Python

I want to install face_recognition for a project that I am about to start. However, face_recognition has a dependency on dlib and I don't know how to install that.
I entered pip install dlib, however, an error was thrown since it said that I needed to install CMake. Here is the error:
Using cached dlib-19.24.0.tar.gz (3.2 MB)
Preparing metadata (setup.py) ... done
Installing collected packages: dlib
DEPRECATION: dlib is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
Running setup.py install for dlib ... error
error: subprocess-exited-with-error
× Running setup.py install for dlib did not run successfully.
│ exit code: 1
╰─> [9 lines of output]
running install
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
running build_ext
ERROR: CMake must be installed to build dlib
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> dlib
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Thus, I tried to install CMake:
Collecting CMake
Using cached cmake-3.25.0-py2.py3-none-win_amd64.whl (32.6 MB)
Installing collected packages: CMake
WARNING: The scripts cmake.exe, cpack.exe and ctest.exe are installed in 'C:\Users\Emma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed CMake-3.25.0
However, when I tried to install dlib again, I got the same error even though I installed CMake successfully.
How could I install dlib now? For reference, I am using a Windows 10 or 11 system, and Python 3.11 64-bit.
Update/Install Visual C++
Maybe try installing/updating Visual C++. Because this is necessary for CMake to run. You can install it from here, https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=15#
Installation with Wheel File
Run this:
pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f
Installation from Internet
Install CMake from https://cmake.org/download/
Run this,
set PATH="%PATH%;C:\Program Files\CMake\bin
to add CMake to your path. You can also do this manually by Editing The Environment Variables.
3)Download the following,
https://pypi.org/project/dlib/#files.
In the specified folder in which you extracted the install files run the following,
python setup.py install.

Unable to Install Jupyter due to legacy-install-error with psutil package

I was previously running into environment inconsistencies after downloading tensorflow with pip in a conda environment, and after several hours of frustration, decided deleting anaconda/miniconda and python and starting from scratch would be my best option to get python working again (The inconsistencies were causing a plethora of issues with loading other modules like numpy, etc).
After downloading Python version 3.9.10 directly from https://www.python.org/downloads/macos/, I wanted to see if I could start using Python again in a Jupyter notebook in VS Code. When I try to run a simple print('hello world') in a python chunk I (unsurprisingly) get the following error:
Jupyter cannot be started. Error attempting to locate jupyter: Running cells with 'Python 3.9.10 64-bit' requires notebook package.
Run the following command to install 'jupyter and notebook' into the Python environment.
Command: 'python -m pip install jupyter notebook -U'
I was pretty much expecting this error, since I knew I had deleted all packages when deleting Anaconda and Python.
However, when I try running python -m pip install jupyter notebook -U in the terminal I ultimately get the following error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> psutil
note: This is an issue with the package mentioned above, not pip.
Any help or insight is greatly appreciated! I am on MacOS (M1) if that is useful information.
The problem seems to be with the python3 distribution that comes with MacOSX Command Line Tools. Well, at least that same error was gone after following these steps.
So, to fix the problem I installed python3.9 (I presume you can change 3.9 to your desired version, e.g. 3.8 or 3.10) using Homebrew.
Install Homebrew (to check if it's installed already just type brew --version in the terminal):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install python3.9
brew install python#3.9
Create your virtual environment
python3.9 -m venv myvenv
Activate the virtual environment with source myvenv/bin/activate
Finally, install Jupyter using
(myvenv) pip install jupyter notebook
I have the same problem when installing the Jupyter notebook on MacOS 12.5 M2 chip. It turns out that the error is caused by not having GCC on my mac to run the wheel for installing the psutil package because for some reason I removed my XCode from my Mac. So I installed XCode from AppStore and opened XCode after the installation to agree to its terms and conditions. After Xcode went through the setup process I tried pip install jupyter again and it worked well.
In my case, I just opened the XCode, accept the terms and the installation proposed, and tried to install the jupyter again and it worked!
It seems to be very particular about the version of python installed. I set up a fresh installation on a new box this morning and put 3.11 on there. pip install jupyterlabs gave me the same error as you got. I then uninstalled python and installed an earlier version, and now it works.
PS the older version that worked for me is 3.10.8

Can not install psycopg2 on Mac 12.3, I keep getting this error

Ive recently bought a MacBook Pro and was setting it up for some python and Django programming but I ended up having problems installing psycopg2, I've tried several things already and none of those worked for me, here left the error,
Collecting psycopg2
Using cached psycopg2-2.9.3.tar.gz (380 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [23 lines of output]
running egg_info
creating /private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/psycopg2.egg-info
writing /private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/psycopg2.egg-info/PKG-INFO
writing dependency_links to /private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/psycopg2.egg-info/dependency_links.txt
writing top-level names to /private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/psycopg2.egg-info/top_level.txt
writing manifest file '/private/var/folders/7f/ssr40bmj6t3_yq0cv_43cttc0000gn/T/pip-pip-egg-info-noe7l09b/psycopg2.egg-info/SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
It shows it is not a problem with pip but with setup.py but can not find anything,
any help would be welcomed
Thanks
As Alex mentioned, it is PostGreSQL being not installed on your system that throws up the error
Install PostGreSQL and it will all work fine
Try this
❯ brew install postgresql
# If you open a new terminal tab you will see that pg_config is available
❯ export CPPFLAGS="-I/opt/homebrew/opt/openssl#1.1/include"
❯ export LDFLAGS="-L/opt/homebrew/opt/openssl#1.1/lib -L${HOME}/.pyenv/versions/3.8.10/lib"
❯ python -V
Python 3.9.13
❯ pip install psycopg2-binary==2.8.6```
Try using the following command:
pip3 install psycopg2-binary
Late, but I just had this problem and nothing I was finding was fixing it. I was trying to install the requirements.txt for an ongoing project on a new Mac. Eventually I remembered it's a postgresql package and I hadn't installed postgresql yet. As soon as I installed postgresql and tried installing psycopg2 again, it worked fine with no errors.

Error installing eth-brownie with pipx: "No Python at: <Location of Old Python Installation>"

I'm trying to install eth-brownie. Followed the Brownie documentation and installed pipx, then ran pipx ensurepath. I was originally using Python 3.10 but couldn't install it, found that this was pretty common and the best fix was to downgrade to 3.9.
After uninstalling 3.10 and installing 3.9, I ran everything again. When I run pipx install eth-brownie, I get the following error:
C:\Users\garri>pipx install eth-brownie
No Python at 'C:\Users\garri\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe'
Fatal error from pip prevented installation. Full pip output in file:
C:\Users\garri\.local\pipx\logs\cmd_2022-03-28_13.40.53_pip_errors.log
Error installing eth-brownie.
I removed Python 3.10 from Path and python --version returns 3.9.12 as expected. I'm at a loss, as I feel like I've tried everything. Any help would be greatly appreciated.
This is basically a pipx cache issue. You have to delete the following folder to remove pipx related cached files.
C:\Users\<username>\.local\pipx

pypy3 import psycopg2 error (undefined symbol: PyCoder_Encoder)

I installed psycopg2 to pypy3(Python3.5.3) by the following code on Ubuntu16.04:
pypy3 -m pip install psycopg2
However, I got some errors:
Error:b'You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.\n'
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-epd368s6/psycopg2
And I found the solution in "You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application".
My computer has already installed Postgresql9.5, so I used these commands to install:
sudo apt-get install libpq-dev
pypy3 -m pip install psycopg2
No error was reported, but when I tried "import psycopg2", I got ImportError:
enter image description here
I found the same error in "pypy3 import psycopg2 error (PyCodec_Encoder)", but I did not found a solution.
Do someone know how to fix it?
The PyPy issue you pointed to contains the answer "Someone will have to implement the missing function (and the other missing PyCodec_* functions. Currently we only implement very few in codec.py. The implementation is quite straight-forward based on the pattern in the functions implemented, the harder part is writing tests.
There is the psycopg2cffi package, which should work on PyPy and will be faster. Perhaps give it a try and comment here if it serves your needs.
psycopg2-binary works with latest version of PyPy 3.6 (nightly build from 2020-01-23) as it contains the PyCodec_Encoder and PyCodec_Decoder implementations.

Resources