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

Can't install sendgrid via setup.py script in Docker image ubuntu 16.04 #379

Closed
DannyLee12 opened this issue Oct 12, 2017 · 7 comments
Closed
Labels
difficulty: medium fix is medium in difficulty status: work in progress Twilio or the community is in the process of implementing type: bug bug in the library

Comments

@DannyLee12
Copy link

DannyLee12 commented Oct 12, 2017

Issue Summary

When installing sendgrid on python 3.6.1 Ubuntu 16.04 in a docker image it throws this error.

Traceback (most recent call last):
  File "setup4.py", line 10, in <module>
    zip_safe=False
  File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/install.py", line 117, in do_egg_install
    cmd.run()
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 411, in run
    self.easy_install(spec, not self.no_deps)
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 653, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 700, in install_item
    self.process_distribution(spec, dist, deps)
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 745, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 863, in resolve
    replace_conflicting=replace_conflicting
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1141, in best_match
    return self.obtain(req, installer)
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1153, in obtain
    return installer(requirement)
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 672, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 698, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 879, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1118, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1104, in run_setup
    run_setup(setup_script, args)
  File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 257, in run_setup
    raise
  File "/usr/local/lib/python3.6/contextlib.py", line 100, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 199, in setup_context
    yield
  File "/usr/local/lib/python3.6/contextlib.py", line 100, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 170, in save_modules
    saved_exc.resume()
  File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 145, in resume
    six.reraise(type, exc, self._tb)
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/_vendor/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 158, in save_modules
    yield saved
  File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 199, in setup_context
    yield
  File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 254, in run_setup
    _execfile(setup_script, ns)
  File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 49, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-raqlxynh/sendgrid-5.2.0/setup.py", line 11, in <module>
  File "/usr/local/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 192: ordinal not in range(128)

I have taken out all other packages. All other packages install without an issue.

Steps to Reproduce

  1. Create a file setup.py that looks like this:

from setuptools import setup, find_packages

setup(
    name='sg_test',
    packages=find_packages(),
    install_requires=[
        'sendgrid',
    ],
    zip_safe=False
)
  1. Run this dockerfile
FROM ubuntu:16.04
RUN apt update
RUN apt install build-essential checkinstall -y
RUN apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -y
RUN wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
RUN tar xvf Python-3.6.1.tar.xz
WORKDIR Python-3.6.1
RUN ./configure
RUN make
RUN make altinstall
RUN curl https://bootstrap.pypa.io/get-pip.py | python3.6

ADD setup.py /code/

WORKDIR /code

RUN python3.6 -m pip install -U pip
RUN python3.6 -m pip install -U setuptools
RUN python3.6 setup.py install

I assume that this is to do with your setup.py I can take a look as well.

Technical details:

  • sendgrid-python Version: master (latest commit: [commit number])
  • Python Version: 3.6.1
@thinkingserious thinkingserious added difficulty: medium fix is medium in difficulty hacktoberfest status: help wanted requesting help from the community type: bug bug in the library labels Oct 12, 2017
@thinkingserious
Copy link
Contributor

Hi @DannyLee12,

Thanks for taking the time to report this!

I have added this to our backlog for review. Perhaps in the meantime, a fix will come via hacktoberfest :)

With Best Regards,

Elmer

@mbernier
Copy link
Contributor

I am not 100% sure, but it looks like maybe the local encoding setting could be set to something other than UTF-8? Based on this:
https://stackoverflow.com/questions/23917729/switching-to-python-3-causing-unicodedecodeerror

@DannyLee12
Copy link
Author

@mbernier python3 supports utf-8 as the default. I'm not setting it anywhere else.

Perhaps this is an issue with docker more than an issue with sendgrid. But all of the other packages that I have tested do install correctly.

in my debugging, the issue appears to be in the exec(code, globals, locals) line.

However, testing the exec command in version works as expected in my docker file. So I don't know if somewhere else in setup.py the default encoding isn't set to ascii?

@akram-rameez
Copy link

I'd like to give this a try, if possible 😃

@akram-rameez
Copy link

@DannyLee12 I tried installing the setup.py you provided with the official python3 image, and it worked perfectly. Can I know exactly why you're trying to use the ubuntu 16.04 image?

I did face some problems installing the Dockerfile you provided, but my issues arose while installing python3, and much before installing sendgrid.

I'll keep you updated on my findings.

@mbernier
Copy link
Contributor

@akram-rameez Thank you!!

@DannyLee12, hitting you up for feedback just in case you didn't see Akram's note.

@mbernier mbernier removed difficulty: medium fix is medium in difficulty difficulty: very hard fix is very hard in difficulty labels Oct 27, 2017
@thinkingserious thinkingserious added status: work in progress Twilio or the community is in the process of implementing difficulty: medium fix is medium in difficulty and removed status: help wanted requesting help from the community labels Feb 27, 2018
@thinkingserious
Copy link
Contributor

@DannyLee12,

Please feel free to reopen if you are still experiencing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: work in progress Twilio or the community is in the process of implementing type: bug bug in the library
Projects
None yet
Development

No branches or pull requests

4 participants