Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Segmentation fault' error when installed from pip but not from conda-forge #56

Closed
rareal opened this issue Nov 12, 2020 · 3 comments
Closed

Comments

@rareal
Copy link

rareal commented Nov 12, 2020

Issue:
When installing pyreadr==0.3.6 from pip , pyreadr.read_r crashes the python process with a 'Segmentation fault' error.
This does not happen when installing from conda-forge


To Reproduce:
Scenario 1 - error

docker run -it --rm --name test_pyreadr --user root jupyter/pyspark-notebook:42f4c82a07ff bash
pip install pyreadr==0.3.6
python
import os
import tempfile
import requests
import pyreadr

test_file_url = "https://github.com/hadley/nycflights13/blob/master/data/airlines.rda?raw=true"
# save to disk
ff = requests.get(test_file_url)
tempdir = tempfile.TemporaryDirectory()
tmp_f_path = os.path.join(tempdir.name, 'tmpfile')
with open(tmp_f_path, 'wb') as tmp:
    tmp.write(ff.content)

result = pyreadr.read_r(tmp_f_path)
# >>> result = pyreadr.read_r(tmp_f_path)
# Segmentation fault

exit

Scenario 2 - working

docker run -it --rm --name test_pyreadr --user root jupyter/pyspark-notebook:42f4c82a07ff bash
conda install -c conda-forge pyreadr==0.3.6 -y
python
import os
import tempfile
import requests
import pyreadr

test_file_url = "https://github.com/hadley/nycflights13/blob/master/data/airlines.rda?raw=true"
# save to disk
ff = requests.get(test_file_url)
tempdir = tempfile.TemporaryDirectory()
tmp_f_path = os.path.join(tempdir.name, 'tmpfile')
with open(tmp_f_path, 'wb') as tmp:
    tmp.write(ff.content)

result = pyreadr.read_r(tmp_f_path)
print(result['airlines'])
#    carrier                         name
# 0       9E            Endeavor Air Inc.
# 1       AA       American Airlines Inc.
# 2       AS         Alaska Airlines Inc.
# 3       B6              JetBlue Airways
# 4       DL         Delta Air Lines Inc.
# 5       EV     ExpressJet Airlines Inc.
# 6       F9       Frontier Airlines Inc.
# 7       FL  AirTran Airways Corporation
# 8       HA       Hawaiian Airlines Inc.
# 9       MQ                    Envoy Air
# 10      OO        SkyWest Airlines Inc.
# 11      UA        United Air Lines Inc.
# 12      US              US Airways Inc.
# 13      VX               Virgin America
# 14      WN       Southwest Airlines Co.
# 15      YV           Mesa Airlines Inc.

exit

Setup Information:
Platform: docker image (jupyter/pyspark-notebook:42f4c82a07ff), running on Docker for Windows. The pip issue also happens with the image python:3-slim.
Python Version: 3.8.6

@ofajardo
Copy link
Owner

Thanks for the report, I can confirm I see the issue on ubuntu running on docker (but not on mac) also with other files. Probably it is something in the environment where the wheels were created (using multibuild on travis), because if I compile from source on ubuntu it is fine.
I'll investigate. For the time being you can either use the conda package or compile from source.

@ofajardo
Copy link
Owner

apparently it is caused by a change in the C code in librdata which in turn makes the wheels behave in a strange way. The issue is reported upstream, hopefully can be solved soon.
At the moment the last version that was working without issues on pip is 0.3.3 in case that information helps.

@ofajardo
Copy link
Owner

solved in version 0.3.7

I also included a function download_file in order to download files from urls. Check it out in the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants