pixel icon indicating copy to clipboard operation
pixel copied to clipboard

Package installation and PyPi distribution

Open AmitMY opened this issue 2 years ago • 7 comments

Trying to install this repository:

pip install git+https://github.com/xplip/pixel

Collecting git+https://github.com/xplip/pixel Cloning https://github.com/xplip/pixel to ./tmp/pip-req-build-ijxd55pn Running command git clone --quiet https://github.com/xplip/pixel /home/nlp/amit/tmp/pip-req-build-ijxd55pn Resolved https://github.com/xplip/pixel to commit efb38f5d54ee04874f61a92aebb3d8403fecf38c Running command git submodule update --init --recursive -q Preparing metadata (setup.py) ... done

Then

python -c "import pixel"

Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'pixel'

I guess it does not install the actual python "package" called "pixel".


If you would add PyPi distribution as well, it would not need to also install the git submodules, which actually takes long as datasets is big.

Here's my suggestion: https://github.com/xplip/pixel/pull/3

However, the name pixel is taken, so you would need to come up with a different pypi package name (this does not change the fact that the installed package will be called pixel)

AmitMY avatar Jul 29 '22 12:07 AmitMY

Thanks for the suggestion! I think it's a good idea to distribute pixel via PyPi. The main reason we currently only support the installation via eggs (running pip install -e git+https://github.com/xplip/pixel#egg=pixel should work) is because we rely on external system libraries (pango, cairo, pangocairo, and their respective dependencies) which need to be installed beforehand, and we give instructions on how to do so here in the repo. If we distributed the package as-is, people would be able to install it from PyPi without a warning and then encounter errors at runtime if they don't have these external libraries installed. I think a good way around this will be to build some Linux and macOS platform wheels for pixel and distribute these via PyPi. I'll try to do that this week :).

xplip avatar Aug 01 '22 12:08 xplip

There's seemingly a missing requirement:

pip install -e git+https://github.com/xplip/pixel#egg=pixel
cd src/pixel
pip install -r requirements.txt
 python -c "import pixel"

ModuleNotFoundError: No module named 'cairo'

(in https://github.com/xplip/pixel/blob/main/src/pixel/data/rendering/pangocairo_renderer.py#L8)

Tried:

conda install -c anaconda cairo
pip install pycairo

But pycairo does not recognize cairo, i'll sort it out. Just wasn't sure if you meant to make it an optional dependency, or had to do it this way as cairo is external, so thought i'll flag it


Note: if there are installation instructions for this repository, I haven't managed to find them

AmitMY avatar Aug 04 '22 14:08 AmitMY

Sorry for the confusion, you can find the installation instructions by clicking on "Show instructions" under https://github.com/xplip/pixel#setup. Maybe I should make it easier to find. If you run this command conda install -c conda-forge pycairo pygobject manimpango instead of installing pycairo via pip, the error should hopefully be resolved.

Alternatively, running sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 libpango1.0-dev libpangocairo-1.0-0 together with pip install pycairo PyGObject manimpango should do the job without conda.

xplip avatar Aug 04 '22 15:08 xplip

I am stuck at cairo not found error. Any suggestion?

FardinAhsanSakib avatar Nov 01 '22 06:11 FardinAhsanSakib

I am stuck at cairo not found error. Any suggestion?

Have you followed the steps above to install cairo / setup your environment? I can try to help identify the problem if you provide some additional information. Could you please 1) paste the exact error message you are getting and let me know 2) when this error occurs (which command you are executing), 3) whether you are using conda, and 4) which operating system you are on?

xplip avatar Nov 01 '22 11:11 xplip

Here is the error message : from pandas.core.computation.check import NUMEXPR_INSTALLED Traceback (most recent call last): File "scripts/training/run_pos.py", line 27, in from pixel import ( File "/scratch/fsakib/CS678/pixel/src/pixel/init.py", line 1, in from .data import * File "/scratch/fsakib/CS678/pixel/src/pixel/data/init.py", line 1, in from .datasets import * File "/scratch/fsakib/CS678/pixel/src/pixel/data/datasets/init.py", line 1, in from .ner_dataset import NERDataset File "/scratch/fsakib/CS678/pixel/src/pixel/data/datasets/ner_dataset.py", line 29, in from ...utils import Modality, Split, get_attention_mask File "/scratch/fsakib/CS678/pixel/src/pixel/utils/init.py", line 9, in from .question_answering import * File "/scratch/fsakib/CS678/pixel/src/pixel/utils/question_answering.py", line 30, in from ..data.rendering import PangoCairoTextRenderer File "/scratch/fsakib/CS678/pixel/src/pixel/data/rendering/init.py", line 1, in from .pangocairo_renderer import * File "/scratch/fsakib/CS678/pixel/src/pixel/data/rendering/pangocairo_renderer.py", line 8, in import cairo ModuleNotFoundError: No module named 'cairo'

After the initial setup, I was trying to do the sanity check in fine-tuning. I am using conda. I am working on a remote server (LInux) where I do not have sudo permission.

FardinAhsanSakib avatar Nov 01 '22 17:11 FardinAhsanSakib

Sorry for the late reply. It seems like cairo is not installed correctly in your conda environment. If you run conda list cairo, you should get an output similar to mine below

conda list cairo
# packages in environment at /home/plip/miniconda3/envs/pixel-env:
#
# Name                    Version                   Build  Channel
cairo                     1.16.0            ha12eb4b_1010    conda-forge
pycairo                   1.21.0           py39h0934665_1    conda-forge

Could you run the same command and check if you have both packages installed, ideally with similar version numbers? If they are both installed, but it still doesn't work, maybe try installing the exact same versions I have via

conda install cairo=1.16.0=ha12eb4b_1010 -c conda-forge
conda install pycairo=1.21.0=py39h0934665_1 -c conda-forge

make sure this matches your python version too (I am using python 3.9). The setup via conda should work fine without having root access. Let me know if this helps!

xplip avatar Nov 07 '22 16:11 xplip