Failing to load packages with pycharm - python

I am trying to do some web scraping using python with PyCharm on a windows 10 machine. Some sites suggest using lxml library and it sounds good. I am trying to load the package but am having trouble. What should I do?
OK great. I go to add lxml 3.6.4 in the package installer and it fails with the message(s):
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
and
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
I installed libxml2dom via the package installer but that does not do the trick
xslt-config is not one of the available packages in the available packages installer
libxml2 is also not an available package
I do not see "libxml2" from the options of available packages. But I do see "libxml2-python" 2.6.21
I tried to install it, but it fails with the message:
Collecting libxml2-python==2.6.21
Could not find a version that satisfies the requirement libxml2-python==2.6.21 (from versions: )
No matching distribution found for libxml2-python==2.6.21
I have been able to load other packages
Using python interpreter 3.5.2
Using PyCharm Community Edition 2016.2.3

lxml needs C/C++ libraries libxml, libxstl so you have to install it first. But they are not Python modules but standard libraries - probably libxml.dll, libxstl.dll.
lxml may need also source code for this libraries or C/C++ header files *.h and C/C++ compiler to compile lxml
For Windows exists Unofficial Windows Binaries for Python Extension Packages with precompiled modules and there is lxml
But much easier (for Windows user) is use Anaconda distribution which installs the same Python from Python.org but with extra, precompiled modules like lxml. See list of modules.
PyCharm can use different Python with different project so you can have installed current Python and Anaconda and use them both in PyCharm.

Related

How to install lxml for Python 3.12?

I am trying to install lxml for my project which is based on Python 3.12 for testing reasons. The problem is related to building the wheel for lxml.
I am still getting:
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
I am using Windows 11 and was trying different approaches:
Putlibxml2.dll in C:\Windows
Put libxml2.dll in C:\Windows\SysWOW64
Put libxml2.dll in another folder and add this folder to Path
Search the internet but the solutions I found are all related to Linux

Installation for pyzmq for Windows fails with error C2143, C4142

I have a windows 7 machine with python 2.7 and I am trying to install pyzmq following these steps. I built libzmq got the binaries and copied them from libzmq\bin\Win32\Debug\v140\dynamic\ to libzmq\lib\ so the next step will work(compiler will have access to /lib and /includes from the same parent folder). But, on this step:
$ python setup.py configure --zmq=../libzmq
I installed pyzmq and libzmq on the same parent folder, as in the installation description related to pyzmq, libzmq is here: ../libzmq
But when I need to configure the pyzmq, I get this error:
I have VS Community 2015 installed and everything seems fine.
ZMQ usually provides sln files that will build from Microsoft Visual Studio. You will have to dig around a little to find it. You are better off trying to get that to work then going directly from the python setup.py that you are currently attempting. Note that you also need libsodium to be built and installed. Thankfully, they also provide Microsoft sln files.
In any case, you are probably better using one of the Python wheels like those from Christoph http://www.lfd.uci.edu/~gohlke/pythonlibs/
Just do
pip install <wheel file>
and you should be good.
Good luck!

Installing Spynner on Python on Windows XP

I have Python 2.7 running on Windows XP. I am trying to install Spynner as an alternative to Mechanize that supports Javascript. When I run easy_install spynner, I get an error while installing lxml:
Make sure the development packages of libxml2 and libxlst are installed
Where can I find those files? I found instructions for linux but no instructions for Windows. I also tried easy_install but it could not find the packages.
Since you are running Windows, try installing lxml from a precompiled binary package. pypi.python.org hosts a binary that you could use. The next run of easy_install should detect the new lxml distribution and the installation should work.

Building lxml on Windows using MinGW

My Python application required lxml. When I tried installing lxml, it the a "vcvrsall.bat not found" error. After digging around on the interwebs, I found that I needed to install MinGW, add it to my PATH variable and modify the distutils.cfg to use this compiler. It worked to the point that it now tried to download the lxml sources and compile it but fails on an error that reads fatal error: libxml/xmlversion.h: No such file or directory. It seems that lxml in turn depends on the libxml C library. How can I install this C library into my MinGW environment so that I can continue building my lxml.
Thanks.
It seems that lxml in turn depends on the libxml C library.
lxml is a python wrapper for the libxml C library.
How can I install this C library into my MinGW environment so that I can continue building my lxml.
Try this tutorial: http://www.pokorra.de/coding/compile_libxml_mingw.html
For lxml, you have to include references to the libxml headers and also have to link against the binaries.
you can download Unofficial Windows Binaries at:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
e.g. for python 2.7 32bit:
http://www.lfd.uci.edu/~gohlke/pythonlibs/3i67tivk/lxml-2.3.3.win32-py2.7.exe

How to specify native library search path for python

I have installed lxml which was built using a standalone version of libxml2. Reason for this was that the lxml needed a later version of libxml2 than what was currently installed.
When I use the lxml module how do I tell it (python) where to find the correct version of the libxml2 shared library?
Assuming you're talking about a .so file, it's not up to Python to find it -- it's up to the operating system's dynamic library loaded. For Linux, for example, LD_LIBRARY_PATH is the environment variable you need to set.

Categories

Resources