Error installing python-docx - python

Trying to install python-docx through pip for 'Learn to Automate the Boring Things with Python'. I am getting errors like this.
I have Googled up some solutions to this issue, but they don't seem to work for me, or I am not deploying the solution correctly.
One post on Stackoverflow said to download an lxml file made available by Christoph Golke.
I downloaded, and then tried 'pip install lxml', and basically got the same error message as the screenshot, telling me 'Unable to find vcvarsall.bat'.
Am I supposed to put this file in a certain directory, before executing that command? Any help would be appreciated.

This mean that C++ Common Tools are not installed.
To install them for Python2.7 go to Microsoft Visual C++ Compiler for Python 2.7
For python3 install Visual Studio Community 2015 and execute the following command:
SET VS90COMNTOOLS=%VS140COMNTOOLS%

so I found the answer to this issue.
So I wasn't aware that to install the lxml file, you first need to change to the directory of that file, and type in the complete name of that file. Either that, or typing the path of the lxml file directly into the cmd prompt, like:
pip install C:\Users\yourName\Downloads\lxml-3.6.4-cp35-cp35m-win32
or
cd C:\Users\yourName\Downloads
pip install lxml-3.6.4-cp35-cp35m-win32
which successfully installed the lxml file, which then led to a successful installation of the python-docx file.
Essentially, a basic knowledge of the command prompt would've helped me avoid this problem...but hope this helps for anyone else who doesn't know what to do!

Related

Trouble installing python packages to target folder (ERROR: Can not combine '--user' and '--target')

I am going through "Automate the Boring Stuff" and I am using Mu as a text editor. I am trying to install a particular package called pyperclip.
Since Mu has its own Python environment, I am trying to install pyperclip into its /pkgs folder. I encounter the following error:
PS C:\Users\MYUSERNAME\AppData\Local\Mu\pkgs> pip install pyperclip --target "C:\Program Files\Mu\pkgs"
ERROR: Can not combine '--user' and '--target'
I have looked around on GitHub and previous posts on learnpython and I have not found similar troubles.
My major confusion is that it says I cannot combine --user but I did not type --user.
I have a feeling the solution is elementary, but I am learning python and how to work with terminals, so I would appreciate someone teaching me what I am doing wrong.
I found this question, whose solution is to reinstall Python from the website, not from the Microsoft app store, but I am pretty sure I downloaed Python from the website. Should I re-download or would that cause more complication?

How to fix Issue with PyAudio in Python

I tried installing Pyaudio in Python but Python says it requires Portaudio binding for the installation.Help me fix this please.My platform is Windows.I am using Python 3.7.2.
I did:
1.I followed the instructions provided in the portaudio website and generated dll file using visual studio.
The portaudio directory where the compiled files are located is my Desktop.
2.Anyway I have installed pyaudio using a setup(exe) file which i found somewhere.
So whenever i type the command "pip install pyaudio", it says the requirements are already fulfilled.
But when i use the alternative command "easy_install pyaudio",it shows an error related to portaudio.
3.And whenever I run a python file which uses pyaudio it again says binding is required.
So, I need the solution to bind Portaudio files which are in my desktop with python.
I searched everywhere for the solution but since I am a beginner, all the tutorials provided in different websites were hard to understand for me.
So please help me with a simple and descriptive solution.
Thanks in advance.
ouch, it seems like you have chosen a painful way to get pyaudio installed.
I never compile on windows, if I can't find a pre-compiled binary I will look around for a different way to get to where I want to (different library…)
you can uninstall with pip uninstall pyaudio
anyways, here's one way to get it working.
download and install a "miniconda" (google if you don't know what it is)
do conda install pyaudio in your "conda"-prompt
I did not truly check the install, but I did the conda install… and it would have installed both portaudio and pyaudio so I suppose it will work.

Installing/Using Pillow on Python 3.6 and Visual Studio

Alright, I need some pointers. I am missing something. I am trying to use Pillow through Python 3.6. The platform I use is Visual Studio 2017. I can't get it to work.
I downloaded Pillow from this website:
https://pypi.org/project/Pillow/
And ran the installer.
According to my research, I need pip to install it; which comes built-in python 3.6. I have seen sign that it is actually installed through my module in visual studio (pip 9.0.3). I simply need to use the following line:
from pip.commands import install
and also tried
import pip
Now, according to this:
https://pillow.readthedocs.io/en/5.2.x/installation.html
All I have to do is
pip install Pillow
Though other sites indicate that PIL is still being used. I have tried both without success. Pillow is not recognized and a error comes in: invalid syntax.
I am clearly doing something wrong. I consulted some youtube tutorial; they all skip that part. They download then go straight to their coding platform and it works.
I can only guess I have additional steps to do with Visual Studio.
Also... The location of my files might be out of whack due to IT security on my work laptop. Could that be an issue?
You can do the following:
python -m pip install pillow
No need to downloade Pillow from the website.
After that, to use it you can do:
import PIL
Thanks for the feedback. I played with Visual Studio some more; there is a way of getting it straight from the menu.
I opened a Python 3.6 project/solution. On the "Python Environment" node in the solution explorer, I right clicked and created a virtual Python environment.
Then I right clicked on the virtual environment and selected "Install Python Package...".
You can then search the package you need for your project.
I don't know if this is the most efficient way. From my research, I think the package are only applicable to my virtual environment; I still have to test that out to make sure.
I may have gone the long way around, but writing the proposed code did not work out. I am sure it works, but I am thinking I might not be using it in the right location.
Anyway, thanks for the help!

Installing modules reliably in one location

I've been working with Python for a little while now but have come to absolutely detest installing new modules. It always seems to take me a full work day to install one additional module. This last happened with mpl_toolkits and now it is happening with gdal.
The main issue seems to be that easy_install/pip/get-app aren't saving a file in the correct location and so Python (I'm using Spyder) can't find it. How do I install a module in a location so that Python can find it?
I have been reading guides, articles, manuals and Stack Overflow articles all day now and I feel this needs a new question as I can't find an answer.
It is installing fine, it's just Python (and I) can't find it
It's not in the /lib/python2.7/site-packages folder, which seems to be the Python default, although half the modules that do work aren't in there when I list it
I installed using:
sudo apt-get install gdal-bin
I also tried with:
pip install gdal
but this fails with the error:
Command "python setup.py egg_info" failed with the error code 1 in /tmp/pip-build-NWJT2f/gdal/
I looked for the files using
dpkg -L gdal
and then added the file path this said into Spyder's preferences option for PYTHONPATH, but it still couldn't find it and so I'm guessing this is wrong.
I have read the official documentation of PYTHONPATH, but it's very short and doesn't really explain it at all.
I recommend trying anaconda or miniconda, which manage environments and install packages - it 'just works'.
https://www.continuum.io/downloads

Installing Pypotrace for python?

Did anybody manage to install pypotrace or is able to install mingwin it's like mission impossible for me I've passed the last 12 hours trying to found out how but nothing is working and description are poor please could any body help? This is where you can get it:
pypotrace web site
This problem was so much of a pain that I ported potrace to python directly rather than using hooks and requiring local compile.
pip install potracer
https://github.com/tatarize/potrace
I implemented the same API as pypotrace so it should be fairly painless.
Since you are working in windows you need the following steps:
You may need the python distutils package - pip install -U distuilts should do the job.
You will also need Cython - the windows installers are here.
You need to install mingw and make sure it is working in
msys mode - run msys and you should get a command prompt in it type
gcc --version and make sure you get a sensible reply.
also make sure your python runs from within msys
Do the required downloads:
potrace source,
agg source site broken or the GitHub zip file here,
potrace source from here and unzip it.
The follow the instructions at the link you gave and tell us where they stop working.

Categories

Resources