How to install lxml for PyPy? - lxml

I've created a virtualenv for PyPy with:
virtualenv test -p `which pypy`
source test/bin/activate
I installed the following dependencies:
sudo apt-get install python-dev libxml2 libxml2-dev libxslt-dev
And then I run:
pip install --upgrade pypy
As a result I get a lot of errors looking like this:
src/lxml/lxml.etree.c:234038:22: error: `PyThreadState` {aka struct _ts}` has no member named `use_tracing`
How do I properly install lxml for PyPy 2.6.0?

I used the following fork of lxml for PyPy instead:
https://github.com/aglyzov/lxml/tree/cffi
It can be installed with:
pip install -e git+git://github.com/aglyzov/lxml.git#cffi#egg=lxml-cffi

Related

I am trying to execute pip install fastapi[all] but it is not working

I want to install Fast API to my mac by entering pip install fastapi[all], it errors.
kanta#Kantas-MacBook-Air fastapi % pip install "fastapi[all]"
zsh: command not found: pip
kanta#Kantas-MacBook-Air fastapi % pip install fastapi[all]
zsh: no matches found: fastapi[all]
kanta#Kantas-MacBook-Air fastapi % pip install fastapi[all]
zsh: no matches found: fastapi[all]
kanta#Kantas-MacBook-Air fastapi % pip install 'fastapi[all]'
zsh: command not found: pip
kanta#Kantas-MacBook-Air fastapi %
I think it is because I am using a mac. Is there a workaround?
You can reach pip via -m flag:
-m mod : run library module as a script (terminates option list)
python3 -m pip install "fastapi[all]"
Note: use python3 or any other alias for your version e.g. python3.10.
Also, I may recommend creating venv for your project.
python3 -m pip install virtualenv
python3 -m virtualenv venv
source venv/bin/activate
pip install "fastapi[all]"
Please try :
pip3 install 'fastapi[all]'

Is Scrapy compatible with Python 3.8 on ubuntu?

While i am try to install scrapy on ubuntu mechine using
**pip install scrapy**
it's not going to workout.
can anyone suggest us?
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
In the documentation, it was mentioned that to install scrapy in a venv on ubuntu based os, we need to install these dependencies sudo apt-get install python3 python3-dev python3-pip libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-dev

Installing scrapy on ubuntu 14.04 fails with error in cryptography setup command Invalid environment marker

I tried installing scrapy on another server.
When I run pip install scrapy:
error in cryptography setup command: Invalid environment marker: python_version < '3'
Complete output from command python setup.py egg_info:
error in cryptography setup command: Invalid environment marker: python_version < '3'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/cryptography
Storing debug log for failure in /root/.pip/pip.log
any ideas please help
Python 2.7.6
I did
sudo apt-get install python-dev python-pip libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-dev
and
sudo apt-get install python-dev python-pip libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-dev
I did an sudo apt-get update before that too
The same happens on debian 8. You can pin the cryptography library on version 2.0.3, then retrying.
pip install cryptography==2.0.3
I just encountered this same issue and solved it via:
pip install --upgrade setuptools pip
Apparently the default version of setuptools and pip on 14.04 is insufficient for the cryptography package.

Python 3.4: using pip

I've read in the documentation that Python3.4 ships with pip installed. When I try to make a call however I get an error. What am I missing?
U:\>py -V
Python 3.4.2
U:\>py -3.4 -m pip install matplotlib
C:\Python34\python.exe: No module named pip

lxml won't install under pypy using easy_install

When doing:
$ sudo pypy -m easy_install lxml
The response is:
Searching for lxml
[...snip...]
ERROR: /bin/sh: 1: xslt-config: not found
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt
/usr/lib/pypy/lib-python/2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
warning: no files found matching '*.txt' under directory 'src/lxml/tests'
src/lxml/lxml.etree.c:8:22: fatal error: pyconfig.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'cc' failed with exit status 1
At the same time, sudo pip install lxml works fine.
What's going on?
Thanks.
sudo apt-get install python-dev fixed it for me on ubuntu 13.04
$yum install python-lxml or apt-get install python-lxml
this solved mine.
I've stumbled with this trouble a couple of times.
Short answer
Python2: $ python2.7 setup.py clean build --with-cython install
Python3: $ pip-3.3 install lxml
Long answer
The hypothesis is that pip install lxml should work in every environment, regardless if you are using Python2 or Python3.
There's also Cython to be considered: You will certainly enjoy lxml compiled with Cython due to relevant performance gains.
For reasons unknown to me, the compilation on Python2 does not find Cython.
To be more precise and absolutely explicit about this matter, both commands below DO NOT employ Cython:
# DO NOT use these commands. I repeat: DO NOT use these commands.
$ pip-2.7 install lxml
$ easy_install-2.7 install lxml
So, when using Python2 you have only one alternative, as far as I know, which is: compile from sources, Luke!
# install build environment and dependencies
$ kernel_release=$( uname -r )
$ sudo apt-get install linux-headers-${kernel_release} build-essential -y
$ sudo apt-get install libxml2-dev libxslt1-dev -y
# Download from github and compile from sources
$ git clone --branch lxml-3.2.4 https://github.com/lxml/lxml
$ python2.7 setup.py clean build --with-cython install
I've handled this problem by installed Ubuntu package pypy-dev.