Python/PyQuery: Unable to find vcvarsall.bat? - python

I have Python 2.7 and I was trying to use PyQuery, so for a test I just typed "import PyQuery" and I got an error:
Traceback (most recent call last):
File "C:\Users\Jacob\Documents\dupes.py", line 1, in <module>
import pyquery
File "C:\Python27\lib\site-packages\pyquery-1.2.1-py2.7.egg\pyquery\__init__.py", line 12, in <module>
from .pyquery import PyQuery
File "C:\Python27\lib\site-packages\pyquery-1.2.1-py2.7.egg\pyquery\pyquery.py", line 8, in <module>
from lxml import etree
ImportError: No module named lxml
So I went to the command prompt and tried to install lxml, but I got this:
Building lxml version 2.3.5.
Building without Cython.
ERROR: 'xslt-config' is not recognized as an internal or external command,
operable program or batch file.
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt
error: Setup script exited with error: Unable to find vcvarsall.bat
I don't really understand what's wrong or what I should do...can someone help?
Thanks.
EDIT:
In response to the comment, I used easy install...

From installation instructions of lxml:
easy_install --allow-hosts=lxml.de,*.python.org lxml
On MS Windows, the above will install the binary builds that we provide. If there is no binary build of the latest release yet, please search PyPI for the last release that has them and pass that version to easy_install like this:
easy_install --allow-hosts=lxml.de,*.python.org lxml==2.2.2
[edit]
Ok, 2.2.2 was en example. I went and looked for you, try:
easy_install --allow-hosts=lxml.de,*.python.org lxml==2.3

Unless your Windows environment is properly set (proper Visual Studio version for your Python version and all that), you should download binary eggs and install them. I know setuptools (and possibly distribute) support installing binary executable packages on Windows (the distutils-based executables only - the ones with the blue background and old dot-matrix Python logo; sorry, but I haven't done Python on Windows in a couple months). Pip doesn't (probably what you are/were using).
But to answer your question, the batch file vcvarsall.bat is used to set the environment variables necessary for building Visual Studio projects/solutions (and generally using any Visual Studio tools) from the command line. It's not in your PATH by default, and since pip is trying to use it to build lxml properly, it fails.
My advice: unless you know how to use Visual Studio command line tools, you're much better off using binary packages on Windows.

Related

Setting up a PyCharm environment for a GTK Hello World on Windows

I'm just trying to make a simple GTK Hello World app run in Pycharm.
I have installed PyCharm Community Edition 2016.2.
I have installed any combination of Anaconda (Python 2, Python 3, 32 bit, 64 bit).
I have downloaded a GTK hello world example
When I try to run this stuff, I first get the error
C:\Users\[...]\Anaconda3\python.exe C:/Users/[...]/PycharmProjects/HelloTk/hellotk.py
Traceback (most recent call last):
File "C:/Users/[...]/PycharmProjects/HelloTk/hellotk.py", line 3, in <module>
import pygtk
ImportError: No module named 'pygtk'
Which I tried to resolve by the instructions on SO: How do I import modules in Pycharm. However, this does not work for the error
Collecting PyGTK
Using cached pygtk-2.24.0.tar.bz2
Complete output from command python setup.py egg_info:
ERROR: Could not import dsextras module: Make sure you have installed pygobject.
Which brought me to the next step, installing pygobject. At first, this failed because of a missing pkg-config, which I installed according the instructions on Stack Overflow How to install pkg config in windows?. This seemed to work, but I now get the error
Collecting PyGObject
Using cached pygobject-2.28.3.tar.bz2
Complete output from command python setup.py egg_info:
* glib-2.0.pc could not be found, bindings for glib._glib will not be built.
ERROR: Nothing to do, glib could not be found and is essential.
Googling more, I found Installing PygObject via PIP in virtualenv, but the solution is for Linux only.
Since ~2h since I installed PyCharm and Anaconda I'm trying to compile a stupid simple Hello World program. How do I make it work and what was I doing wrong?
You need to download the latest installer for windows from: https://sourceforge.net/projects/pygobjectwin32/files/?source=navbar
Also, you must make sure you are not running python 3.5 or newer, the last supported version seems to be 3.4.x for GTK.
It took me a few hours to figure this out as the installer completes without complaining at all on 3.5 as well, it just doesn't install the package.
Regards,
Hunor
Edit: so, while this sort of works to install, i still can't get quite a few things to work in it :(

Installing bsddb3 6.1.1 in Windows: FileNotFoundError: 'db/include\\db.h'

I'm running Windows 7 x64, with Python 3.4. When I run pip install bsddb3 I get:
λ pip install bsddb3
Collecting bsddb3
Using cached bsddb3-6.1.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "C:\Users\User\AppData\Local\Temp\pip-build-soqf0_qb\bsddb3\setup.py", line 42, in <module>
import setup3
File "C:\Users\User\AppData\Local\Temp\pip-build-soqf0_qb\bsddb3\setup3.py", line 375, in <module>
with open(os.path.join(incdir, 'db.h'), 'r') as f :
FileNotFoundError: [Errno 2] No such file or directory: 'db/include\\db.h'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\User\AppData\Local\Temp\pip-build-soqf0_qb\bsddb3
So I tried downloading the sources for bsddb3. I made sure I had the BSD DB Windows binaries from Oracle installed; I downloaded them from Berkeley DB 6.1.26.msi. Moving the include and lib directories from the DB install to a /db directory in the bsddb3 folder fixed the problem of not being able to find the libraries. But then the setup failed on a missing variable that's in the posix section but not properly declared in the Windows section.
Fixing that, and a couple of other adjustments, and python setup.py build actually ran the build, but after a bunch of warnings about unsafe conversions it failed with an error:
warning: I don't know what to do with 'runtime_library_dirs': ['db/lib']
error: don't know how to set runtime library search path for MSVC++
I'm not sure what to do next. Other than rewrite the library I was originally trying to use so that it uses SQLAlchemy instead or something.
One don't really want to spend couple of nights compiling that on Windows, so the best option is to use pre-built binary from Unofficial Windows Binaries for Python Extension Packages.
Download the package for your Python version (cpXX part of the name) and architecture (win_amd64 or win32), like bsddb3-6.1.1-cp34-none-win_amd64.whl, and install it with pip:
pip install bsddb3-6.1.1-cp34-none-win_amd64.whl
Based on cyberj0g's answer.
https://www.lfd.uci.edu/~gohlke/pythonlibs/#bsddb3
pip install bsddb3-6.1.1-cp34-none-win_amd64.whl
Note: the cp part is corresponding to the CPython version.
which means cp36 is for CPython 3.6.And divided into 32-bit and 64-bit versions for windows
bsddb3‑6.2.5‑cp36‑cp36m‑win32.whl
bsddb3‑6.2.5‑cp36‑cp36m‑win_amd64.whl

Error when importing python igraph in OSX 10.10.5 by anaconda (libxml2.2.dylib)

I installed the python igraph library for anaconda following the directions in this thread installing python igraph, So the C core library and the python package were successfully installed. However, when I tried to import the igraph library in python, I am getting the following error
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/user/anaconda/lib/python2.7/site-packages/igraph/__init__.py", line 34, in <module>
from igraph._igraph import *
ImportError: dlopen(/Users/user/anaconda/lib/python2.7/site-packages/igraph/_igraph.so, 2): Library not loaded: libxml2.2.dylib
Referenced from: /Users/user/anaconda/lib/python2.7/site-packages/igraph/_igraph.so
Reason: Incompatible library version: _igraph.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0
Looking for similar threads, I found a similar issue here Installation of python igraph with lxml problem. However, there is not a clear way on how to solve this issue. Does anyone know how to fix it? Thanks in advance.
Anaconda Python is weird - it ships with its own version of libxml2 and when you run pip install python-igraph, igraph is probably linked against it. However, when you try to import igraph, the linker finds the system-wide libxml2, which has a lower ABI version, so that's why you see the error message.
The workaround for this is to ensure that during the compilation stage, Anaconda Python's libxml2 is not picked up by the compiler. setup.py in the Python interface of igraph actually contains this workaround - it tries to detect when you are compiling igraph against Anaconda Python on OS X and then it tweaks the environment a bit to ensure that the linker picks up the right version of libxml2. However, this workaround is enabled only if you do not have the C core of igraph installed on your machine - the installer will download the C core, tweak the environment to work around Anaconda Python, then compile the C core and the Python interface together in one single step.
So, the solution is probably one of the following:
Move Anaconda Python's libxml2 out of the way (or maybe rename xml2-config from Anaconda Python's distribution temporarily), then compile and install the C core from Homebrew. (Use brew unlink igraph, brew uninstall igraph, brew install igraph to be on the safe side). Then you can run pip install python-igraph.
Remove Homebrew's igraph entirely and just run pip install python-igraph - it will download the C core, perform the necessary tweaks and then compile everything.
I had exactly the same issue and installing/force linking libxml2 worked for me:
brew install libxml2
brew link --force libxml2
Others also report the same solution and it appears to be working.

Error installing Willie irc bot for Python

Trying to install this Python IRC bot called Willie. This is what happens when I run setup.py:
C:\Python34\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.1\helpers\pycharm\pycharm_setup_runner.py" C:\Users\Quibbles\Documents\willie-5.3.0\setup.py
Testing started at 1:35 PM ...
running pycharm_test
Searching for pygeoip
Best match: pygeoip 0.3.2
Processing pygeoip-0.3.2-py3.4.egg
Using c:\users\quibbles\documents\willie-5.3.0\.eggs\pygeoip-0.3.2-py3.4.egg
Searching for pyenchant
Best match: pyenchant 1.6.6
Processing pyenchant-1.6.6-py3.4-win32.egg
Using c:\users\quibbles\documents\willie-5.3.0\.eggs\pyenchant-1.6.6-py3.4-win32.egg
Searching for praw
Best match: praw 2.1.21
Processing praw-2.1.21-py3.4.egg
Using c:\users\quibbles\documents\willie-5.3.0\.eggs\praw-2.1.21-py3.4.egg
Searching for lxml
Reading https://pypi.python.org/simple/lxml/
Best match: lxml 3.4.4
Downloading https://pypi.python.org/packages/source/l/lxml/lxml-3.4.4.tar.gz#md5=a9a65972afc173ec7a39c585f4eea69c
Processing lxml-3.4.4.tar.gz
Writing C:\Users\Quibbles\AppData\Local\Temp\easy_install-p_x9naya\lxml-3.4.4\setup.cfg
Running lxml-3.4.4\setup.py -q bdist_egg --dist-dir C:\Users\Quibbles\AppData\Local\Temp\easy_install-p_x9naya\lxml-3.4.4\egg-dist-tmp-0expfysa
Building lxml version 3.4.4.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt
C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
cl : Command line warning D9025 : overriding '/W3' with '/w'
lxml.etree.c
C:\Users\Quibbles\AppData\Local\Temp\easy_install-p_x9naya\lxml-3.4.4\src\lxml\includes\etree_defs.h(14) : fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': No such file or directory
error: Setup script exited with error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\cl.exe' failed with exit status 2
Process finished with exit code 1
What am I doing wrong? I downloaded the source code from https://github.com/embolalia/willie/releases/tag/v5.3.0 and tried running setup.py in PyCharm.
It should be fairly obvious by the error messages:
** make sure the development packages of libxml2 and libxslt are installed **
You need to have the dev libxml2 and libxslt installed. It appears either you have the wrong versions perhaps, or don't have them installed properly.
I'L'I's answer gives you a hint of where to start searching next, but isn't a useful answer.
After several attempts on my own, I found that to get the lxml library installed, I needed to do the following:
First, download the lxml library from http://www.lfd.uci.edu/~gohlke/pythonlibs/
This is necessary because the PiPy archives (https://pypi.python.org/pypi/lxml/3.4.4) are way out of date, only giving you the option to install for Python 3.2 for the 3+ series, which of course is useless if you're on 3.4. There's also issues if you're using 64-bit. They may be sufficient if you're using 2.7, though.
Then use the instructions here: How do I install a Python package with a .whl file? to install the .whl file.
However that only fixes half the problem. The willie package appears to be broken in other ways (on Windows) because of trying to reference a unix-like /tmp directory (absolute path) instead of the proper Windows Temp directory.
This issue describes the problem, though no fix has yet been made: https://github.com/embolalia/willie/issues/811
It indicates that it's a Windows-specific bug in the installer. To work around that, download the .tar.gz from https://pypi.python.org/pypi/willie/5.3.0
Unpack it. Go to the willie-5.3.0\willie.egg-info directory, and edit the SOURCES.txt file. The fifth line is /tmp/tmpeAhjCF/willie. Delete that line.
Repackage the directory into a .tar.gz archive. Install via pip install .\willie-5.3.0.tar.gz.
Now it's installed, and you're ready for the next round of problems of actually getting it to run on Windows. Since I haven't actually succeeded in doing that yet, that's as far as I can help for right now.

installing paramiko on Windows

This may sound like a repeated question on SF, but I could not find a clear answer to it, yet.So.
I installed Paramiko 1.7 with "setup.py install" command and while running the demo.py program, I got this error:
Traceback (most recent call last):
File "C:\Documents and Settings\fixavier\Desktop\paramiko-1.7\demos\demo.py", line 33, in <module>
import paramiko
File "C:\Python26\lib\site-packages\paramiko\__init__.py", line 69, in <module>
from transport import randpool, SecurityOptions, Transport
File "C:\Python26\lib\site-packages\paramiko\transport.py", line 32, in <module>
from paramiko import util
File "C:\Python26\lib\site-packages\paramiko\util.py", line 31, in <module>
from paramiko.common import *
File "C:\Python26\lib\site-packages\paramiko\common.py", line 99, in <module>
from Crypto.Util.randpool import PersistentRandomPool, RandomPool
ImportError: No module named Crypto.Util.randpool
I'm getting this error even after installing PyCrypto 2.1.
On running test.py(which comes with the installation), I got the following error -
Traceback (most recent call last):
File "C:\Documents and Settings\fixavier\Desktop\pycrypto-2.0.1\pycrypto-2.0.1\test.py", line 18, in <module>
from Crypto.Util import test
File "C:\Documents and Settings\fixavier\Desktop\pycrypto-2.0.1\pycrypto-2.0.1\build/lib.win32-2.6\Crypto\Util\test.py", line 17, in <module>
import testdata
File "C:\Documents and Settings\fixavier\Desktop\pycrypto-2.0.1\pycrypto-2.0.1\test\testdata.py", line 450, in <module>
from Crypto.Cipher import AES
ImportError: cannot import name AES
I don't have the confidence to go ahead and install AES after all this, for all I know I may get another ImportError!
Please advice.Is it the way of installation thats problematic?
Looks like your pycrypto installation is broken or not installed.
Try to get a pycrypto for python2.6 installer here and try again after installing it.
http://www.voidspace.org.uk/python/modules.shtml#pycrypto
I tried Vijay's method,but it doesn't work.
I use the method on 'http://kmdarshan.com/blog/?p=3208',it works:
Goto to http://twistedmatrix.com/trac/wiki/Downloads and download the pycrypto package .exe for windows/python2.5. This is needed for running paramiko.
Next, download the paramiko package from http://www.lag.net/paramiko/.
Unzip paramiko to a temporary folder, better if you unzip it to the folder where python is installed.
Go into the folder for paramiko.
Open command prompt and see to it that you have python set as the environment variable.
Run this command python setup.py install
You will get a series of lines of compilation. Just make sure you dont have any error in them. If you have any errors you will need to re compile them again.
Just be be sure everything is alright import paramiko in your program and see.
FYI: paramiko is used for ssh..and so on.
Download paramiko for windows. You get the zip file:
www.lag.net/paramiko/
To build it you need the dependency package pycrypto. Again keep in mind you will need a matching version of pycrypto for your Python. This is a built version of Windows so no install is required. http://www.voidspace.org.uk/python/modules.shtml#pycrypto
You could do an easy_install by downloading setuptools but I ran into some issues so I chose to download MinGW tool. This is again an installation and no build is required. http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/mingw-get-inst-20110316/
Once you have pycrypto and MinGW installed on your windows machine, just browse to the folder where you extracted the paramiko module from the zip file and issue this command:
python setup.py build --compiler=mingw32 bdist_wininst
TADA! You are all set to use ssh on your windows machine with Python.
I have installed paramiko onto 64bit Windows 7 successfully:
Install Python2.7
Download 64bit PyCrypto installation package from: http://www.dragffy.com/posts/ython-pycrypto-2-4-1-32-and-64-bit-windows-32x64-amdintel-installers
Download paramiko package from: http://www.lag.net/paramiko/
extract paramiko package
start a command line terminal from the extracted paramiko package, run
"python setup.py install"
I wanted to install Paramiko for Python 3.3.2 on Windows XP. I followed the instructions here
After I downloaded all programs on the list for my Python version, Paramiko starts without problems.
Install python-2.7.3.amd64.msi
Install pycrypto-2.6.win-amd64-py2.7.exe
Install setuptools-1.4.2.win-amd64-py2.7.exe
Install pip-1.4.1.win-amd64-py2.7.exe
Download and extract https://github.com/paramiko/paramiko/archive/master.zip
The actual problem does not seem to be a broken Crypto install but a slightly different one. After installing paramiko and crypto with easy_install on windows I do have crypto installed but not Crypto. I installed the package PyCrypt (which gave an error because I didn't have a C compiler before I installed visual studio express)
It appears that the Crypto package you downloaded doesn't have AES...
you should try doing the following:
import Crypto
import Crypto.Util
import Crypto.Cipher
if any of those fail then you still need to make sure pycrypto is installed (see the link from S.Mark here), otherwise Paramiko might not depend on having AES (even though there is a test for that)
It seems PyCrypto uses a c-compiler(which is inherently present on the Linux system - gcc).
Also, somewhere on the PyCrypto readme.txt file says, it needs to be 'build' first, before doing an 'install'
On Linux, I build it first and then ran 'install' command on it and was successfully installed.
I searched for a long time looking for a solution to this problem. I'm running Windows 7 64-bit and python 2.7. None of the above solutions worked for me.
this one did
Don't forget to include the C++ compiler when you download the Microsoft SDK, it wasn't checked by default.
I downloaded the pycrypto 2.5 source to do the compile and the paramiko 2.3, things work well.
Here is a very precise answer:
Step 1: Go to https://github.com/paramiko/paramiko
Step 2: Download the zip file, and extract it
Step 3: Move into the folder and run python setup.py install
You are done!
I had the similar problem on my mac and the way I solved it was by simply just renaming the "crypto" directory to the "Crypto". I already had the paramiko and ssh installed in it. They both work perfectly fine now. However, this may or may not work for some one but this is just a simple thought on getting the ways around this problem.
just try
pip install paramiko
if this shows error, then
pip install cryptography
pip install paramiko

Categories

Resources