Coder Social home page Coder Social logo

captcha's People

Contributors

0xflotus avatar ajfv avatar bigborg avatar brucedone avatar camel007 avatar contracode avatar dshaw0004 avatar emedvedev avatar eromoe avatar klkvr avatar leechristophermurray avatar lepture avatar nagos avatar peppelinux avatar silencewwt avatar virajmane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

captcha's Issues

AssertionError

I run the demo(just the ImageCaptcha part) and it works fine to generate a captcha. But there's an AssertionError when I run "data = image.generate('1234')".

The demo isn't working.

[#24#wangx@wangxiang-PC:~]$cat test.py
from io import BytesIO
from captcha.image import ImageCaptcha

image = ImageCaptcha(fonts=['/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf', '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf'])

data = image.generate('1234')
assert isinstance(data, BytesIO)
image.write('1234', 'out.png')
[#25#wangx@wangxiang-PC:~]$python3 test.py
Traceback (most recent call last):
File "test.py", line 6, in
data = image.generate('1234')
File "/usr/local/lib/python3.4/dist-packages/captcha/image.py", line 40, in generate
im = self.generate_image(chars)
File "/usr/local/lib/python3.4/dist-packages/captcha/image.py", line 220, in generate_image
self.create_noise_curve(im, color)
File "/usr/local/lib/python3.4/dist-packages/captcha/image.py", line 132, in create_noise_curve
Draw(image).arc(points, start, end, fill=color)
File "/usr/lib/python3/dist-packages/PIL/ImageDraw.py", line 164, in arc
self.draw.draw_arc(xy, start, end, ink)
TypeError: must be sequence of length 4, not 2

My environment:
ubuntu 14.04
Python 3.4.0
PIL 1.1.7

it doesn't work under (ubuntu18.04 captcha 0.3 pillow 6.0.0 python 3.6.7)

I am a fresh coder, I am already find it from google, but...
this is my question, how can i solve it?
code:

    image = ImageCaptcha(fonts=['./ihome/utils/captcha/fonts/actionj.ttf', './ihome/utils/captcha/fonts/Georgia.ttf'])
    str1 = 'abcd123efghijk45lmn6opqrst789uvwxyz0'
    text = ''
    for i in range(0, 4):
        text += str1[random.randrange(0, len(str1))]
    image_data = image.generate(text)

ERROR:
Traceback (most recent call last):
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/PIL/ImageFile.py", line 488, in _save
fh = fp.fileno()
AttributeError: '_idat' object has no attribute 'fileno'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/app.py", line 2328, in call
return self.wsgi_app(environ, start_response)
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/app.py", line 2314, in wsgi_app
response = self.handle_exception(e)
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/app.py", line 1760, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/_compat.py", line 36, in reraise
raise value
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/app.py", line 2311, in wsgi_app
response = self.full_dispatch_request()
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/app.py", line 1834, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/app.py", line 1737, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/_compat.py", line 36, in reraise
raise value
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/flask/app.py", line 1818, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/icmelon/virtual_environment/flask/flask/bin/ihome_project/ihome/api_1_0/verify_code.py", line 21, in get_image_codes
image_data = image.generate(text)
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/captcha/image.py", line 47, in generate
im.save(out, format=format)
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/PIL/Image.py", line 2007, in save
save_handler(self, fp, filename)
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/PIL/PngImagePlugin.py", line 896, in _save
[("zip", (0, 0)+im.size, 0, rawmode)])
File "/home/icmelon/virtual_environment/flask/flask/lib/python3.6/site-packages/PIL/ImageFile.py", line 502, in _save
l, s, d = e
TypeError: 'ImagingEncoder' object is not iterable

But pillow 5.0.0 can work!

Using different fonts?

Hi, I'm testing out your module and was wondering what file format do the fonts have to be in?
Is there a safe site you can recommend where I can grab different types of fonts that would work with your module? Thank you for your hard work.

ImageCaptcha incomplete

In the test environment is complete, the online environment is not complete
image
captcha==0.2.1

DeprecationWarning in Pillow 10

I got following DeprecationWarning.
Environment is Ubuntu 20.04 / Python3.10

captcha/image.py:192: DeprecationWarning: QUAD is deprecated and will be removed in Pillow 10 (2023-07-01). Use Transform.QUAD instead.
im = im.transform((w, h), Image.QUAD, data)

captcha/image.py:165: DeprecationWarning: textsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use textbbox or textlength instead.
w, h = draw.textsize(c, font=font)

captcha/image.py:174: DeprecationWarning: BILINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BILINEAR instead.
im = im.rotate(random.uniform(-30, 30), Image.BILINEAR, expand=1)

Audio files not supported on Safari 11 desktop

I got the response DOMError {name: "NotSupportedError", message: "The operation is not supported."} on the following HTML when I play the captcha sound:

var a = new Audio("https://xxxxxxxxxx.com/captcha/audio/52d3c6188d2fb733480ce2198a7fde4ec1e9d579");
// var a = new Audio("https://www.w3schools.com/html/horse.mp3"); // works!
// var a = new Audio("http://www.wavsource.com/snds_2017-09-17_1751672946049674/movie_stars/deniro/meet_parents_bring_u_down.wav");  // works!
var promise = a.play();
promise.catch(error => {
	console.log(error)
})
.then(() => {
	console.log('success, it played!')
})

Can't install captcha in Python 3.5

I use command: pip3 install captcha
The exception info: Could not find a version that satisfies the requirement captcha (from versions: )
No matching distribution found for captcha

So the captcha module can't support Python3?

it doesn't work under python 3.6 and Mac OS X 10.12.

I got some error when I install captcha in my mac.

>>> import captcha.image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/captcha/image.py", line 11, in <module>
    from PIL import Image
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/Image.py", line 60, in <module>
    from . import _imaging as core
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/_imaging.cpython-36m-darwin.so, 2): Symbol not found: _clock_gettime
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/.dylibs/liblzma.5.dylib (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib
 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/.dylibs/liblzma.5.dylib

You can see that it doesn't work under python 3.6 and Mac OS X 10.12.

so I change pillow from 5.1.0 to 5.0.0, it's all fine now ! :)

$ pip install pillow==5.0.0
...
Installing collected packages: pillow
  Found existing installation: Pillow 5.1.0
    Uninstalling Pillow-5.1.0:
      Successfully uninstalled Pillow-5.1.0
Successfully installed pillow-5.0.0

Perhaps many people will happen this error because they like to choose the newest version of every packages, so I must report above message : )

force_text deprecated in Django 4

Hi,

I'm getting my site ready to upgrade to Django 4, and hitting the following error when migrating:

$ python manage.py migrate
Traceback (most recent call last):
  File "<directory>\manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "<directory>\.venv\lib\site-packages\django\core\management\__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "<directory>\.venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute        
    django.setup()
  File "<directory>\.venv\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "<directory>\.venv\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
  File "<directory>\.venv\lib\site-packages\django\apps\config.py", line 300, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Program Files\Python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<directory>\home\models.py", line 2, in <module>
    from core.models import SEOPage
  File "<directory>\core\models.py", line 8, in <module>
    from wagtailcaptcha.models import WagtailCaptchaEmailForm
  File "<directory>\.venv\lib\site-packages\wagtailcaptcha\models.py", line 4, in <module>
    from .forms import WagtailCaptchaFormBuilder, remove_captcha_field
  File "<directory>\.venv\lib\site-packages\wagtailcaptcha\forms.py", line 4, in <module>
    from captcha.fields import ReCaptchaField
  File "<directory>\.venv\lib\site-packages\captcha\fields.py", line 11, in <module>
    from django.utils.encoding import force_text
ImportError: cannot import name 'force_text' from 'django.utils.encoding' (<directory>\.venv\lib\site-packages\django\utils\encoding.py)

Versions:
captcha 0.3
wagtail-django-recaptcha 1.0
wagtail 2.16

Seems the call to the force_text library in fields.py needs updating before the upgrade - is there any plan to make this package compatible with Django 4? It's the only thing blocking my upgrade at this stage.

No module named captcha.audio

Requirement already satisfied: captcha in /usr/local/lib/python3.6/dist-packages (0.3)
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (from captcha) (5.1.0)
limu2048@ubuntu:~$ cd /usr/local/lib/python3.6/dist-packages
limu2048@ubuntu:/usr/local/lib/python3.6/dist-packages$ ls
captcha
captcha-0.3.dist-info

I think I successfully install captcha?
But when I import it, it shows the error info below:

No module named captcha.audio

Can you help me? I'm new to python and I've stuck in this problem for a day.

installation error "error: command 'x86_64-linux-gnu-gcc' failed with exit status 1"

   pip install captcha
 ---> Running in e2be2644b653
Downloading/unpacking captcha
Downloading/unpacking Pillow (from captcha)
  Running setup.py (path:/tmp/pip_build_root/Pillow/setup.py) egg_info for package Pillow
    Single threaded build, not installing mp_compile:1 processes

    warning: no files found matching '*.sh'
    no previously-included directories found matching 'docs/_static'
    warning: no previously-included files found matching '.coveragerc'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.landscape.yaml'
    warning: no previously-included files found matching 'appveyor.yml'
    warning: no previously-included files found matching 'build_children.sh'
    warning: no previously-included files found matching 'tox.ini'
    warning: no previously-included files matching '.git*' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
Installing collected packages: captcha, Pillow
  Running setup.py install for Pillow
    Single threaded build, not installing mp_compile:1 processes

    warning: no files found matching '*.sh'
    no previously-included directories found matching 'docs/_static'
    warning: no previously-included files found matching '.coveragerc'
    warning: no previously-included files found matching '.editorconfig'
    warning: no previously-included files found matching '.landscape.yaml'
    warning: no previously-included files found matching 'appveyor.yml'
    warning: no previously-included files found matching 'build_children.sh'
    warning: no previously-included files found matching 'tox.ini'
    warning: no previously-included files matching '.git*' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    building 'PIL._imaging' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_LIBJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -I/usr/include/freetype2 -I/tmp/pip_build_root/Pillow/libImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_64-2.7/_imaging.o
    _imaging.c:76:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-XRWOt3-record/install-record.txt --single-version-externally-managed --compile:
    Single threaded build, not installing mp_compile:1 processes

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

creating build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageTk.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/FliImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImagePalette.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageCms.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageQt.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/_util.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageStat.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageMorph.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageColor.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/GifImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageDraw2.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/GimpGradientFile.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageEnhance.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageDraw.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/OleFileIO.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/WalImageFile.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageFont.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/TiffTags.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PaletteFile.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/DdsImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageWin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageShow.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/SunImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImagePath.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/MspImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/BdfFontFile.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/CurImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageMath.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageFile.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageChops.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/GdImageFile.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/features.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/FontFile.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/JpegPresets.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageGrab.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PcfFontFile.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageTransform.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PSDraw.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/_binary.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/FtexImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/MicImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ContainerIO.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/TarIO.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/__init__.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/Image.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageSequence.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PngImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ExifTags.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageOps.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageFilter.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/ImageMode.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL

copying PIL/PyAccess.py -> build/lib.linux-x86_64-2.7/PIL

running egg_info

writing Pillow.egg-info/PKG-INFO

writing top-level names to Pillow.egg-info/top_level.txt

writing dependency_links to Pillow.egg-info/dependency_links.txt

warning: manifest_maker: standard file '-c' not found



reading manifest file 'Pillow.egg-info/SOURCES.txt'

reading manifest template 'MANIFEST.in'

warning: no files found matching '*.sh'

no previously-included directories found matching 'docs/_static'

warning: no previously-included files found matching '.coveragerc'

warning: no previously-included files found matching '.editorconfig'

warning: no previously-included files found matching '.landscape.yaml'

warning: no previously-included files found matching 'appveyor.yml'

warning: no previously-included files found matching 'build_children.sh'

warning: no previously-included files found matching 'tox.ini'

warning: no previously-included files matching '.git*' found anywhere in distribution

warning: no previously-included files matching '*.pyc' found anywhere in distribution

warning: no previously-included files matching '*.so' found anywhere in distribution

writing manifest file 'Pillow.egg-info/SOURCES.txt'

copying PIL/OleFileIO-README.md -> build/lib.linux-x86_64-2.7/PIL

running build_ext

building 'PIL._imaging' extension

creating build/temp.linux-x86_64-2.7/libImaging

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_LIBJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -I/usr/include/freetype2 -I/tmp/pip_build_root/Pillow/libImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu -c _imaging.c -o build/temp.linux-x86_64-2.7/_imaging.o

_imaging.c:76:20: fatal error: Python.h: No such file or directory

 #include "Python.h"

                    ^

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Why not work?

error:
raise importerror("the _imagingft c module is not installed")

Voice sources

You may be interested in the CC0-licensed Mozilla's Common Voice.

Each entry in the dataset consists of a unique MP3 and corresponding text file. Many of the 4,257 recorded hours in the dataset also include demographic metadata like age, sex, and accent that can help train the accuracy of speech recognition engines. The dataset currently consists of 3,401 validated hours in 40 languages, but we’re always adding more voices and languages. Take a look at our Languages page to request a language or start contributing.

Forvo too has a huge dataset of pronounced words and sentences, but they are not as eager as Mozilla to share it.

Unable to run "Getting Started" snippet; "ModuleNotFoundError" and circular import error

Python and Captcha Versions

Python version:

➜  python --version
Python 3.8.2

Captcha version

➜  python -m pip freeze
...
captcha==0.3
...

Problem Statement

After running python -m pip install captcha and then pasting the example snippet from the README into a file called captcha.py:

from captcha.audio import AudioCaptcha
from captcha.image import ImageCaptcha

audio = AudioCaptcha(voicedir='/path/to/voices')
image = ImageCaptcha(fonts=['/path/A.ttf', '/path/B.ttf'])

data = audio.generate('1234')
audio.write('1234', 'out.wav')

data = image.generate('1234')
image.write('1234', 'out.png')

I get the following error when running the file:

➜  python captcha.py
Traceback (most recent call last):
  File "captcha.py", line 1, in <module>
    from captcha.audio import AudioCaptcha
  File "[redacted_full_path]/captcha.py", line 1, in <module>
    from captcha.audio import AudioCaptcha
ModuleNotFoundError: No module named 'captcha.audio'; 'captcha' is not a package

If I change the file slightly to:

import captcha

audio = captcha.audio.AudioCaptcha(voicedir='/path/to/voices')
image = captcha.image.ImageCaptcha(fonts=['/path/A.ttf', '/path/B.ttf'])

I get the following error when running the file:

➜  python captcha.py
Traceback (most recent call last):
  File "captcha.py", line 1, in <module>
    import captcha
  File "[redacted_full_path]/captcha.py", line 3, in <module>
    audio = captcha.audio.AudioCaptcha(voicedir='/path/to/voices')
AttributeError: partially initialized module 'captcha' has no attribute 'audio' (most likely due to a circular import)

Image cut when using some font

out
I think the reason is that PIL's textsize() function does not consider the offset of the font.
python-pillow/Pillow#644
I don't know it is a bug or feature for PIL, But you can fix this by just adding the offset the w and h in _draw_character() function.

TypeError: 'float' object cannot be interpreted as an integer on Python 3.10.0

~ # python3
Python 3.10.0 (default, Nov 13 2021, 03:23:03) [GCC 10.3.1 20210424] on linux
Type "help", "copyright", "credits" or "license" for more information.

from captcha.image import ImageCaptcha

image = ImageCaptcha()
data = image.generate("chars")
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.10/site-packages/captcha/image.py", line 45, in generate
im = self.generate_image(chars)
File "/usr/local/lib/python3.10/site-packages/captcha/image.py", line 228, in generate_image
im = self.create_captcha_image(chars, color, background)
File "/usr/local/lib/python3.10/site-packages/captcha/image.py", line 212, in create_captcha_image
mask = im.convert('L').point(table)
File "/usr/local/lib/python3.10/site-packages/PIL/Image.py", line 1680, in point
return self._new(self.im.point(lut, mode))
TypeError: 'float' object cannot be interpreted as an integer

~ # pip list
Package Version


captcha 0.3
Pillow 8.4.0
pip 21.2.4
setuptools 57.5.0
wheel 0.37.0

create_captcha_image broken

With the release of Pillow 10, the dependency of this module on Pillow (without version specifier) will now install Pillow 10.

This causes create_captcha_image to break:

  File "/usr/local/lib/python3.11/site-packages/captcha/image.py", line 45, in generate
    im = self.generate_image(chars)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/captcha/image.py", line 228, in generate_image
    im = self.create_captcha_image(chars, color, background)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/captcha/image.py", line 198, in create_captcha_image
    images.append(_draw_character(" "))
                  ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/captcha/image.py", line 165, in _draw_character
    w, h = draw.textsize(c, font=font)
           ^^^^^^^^^^^^^
AttributeError: 'ImageDraw' object has no attribute 'textsize'

A potential fix could be pinning to an older Pillow version (will likely cause other problems), or fixing the issue itself. https://pillow.readthedocs.io/en/stable/releasenotes/10.0.0.html#font-size-and-offset-methods hints at how to do that.

TypeError: expected string

I wrote the following code:

(Python 3.10.2)

def generate_captcha():
    captcha_text = ''.join(random.sample('1234567890', 4))
    image = ImageCaptcha(fonts=['captcha_fonts/Joseon-Regular.ttf'])
    data = image.generate(captcha_text)
    image.write(data, f'/captcha/{captcha_text}.png')
    return 1

but I got the following error:


expected string
Traceback (most recent call last):
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\venv\lib\site-packages\pyrogram\dispatcher.py", line 222, in handler_worker
await handler.callback(self.client, *args)
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\bot.py", line 33, in start_handler
data = generate_captcha()
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\bot.py", line 24, in generate_captcha
image.write(data, f'/captcha/{captcha_text}.png')
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\venv\lib\site-packages\captcha\image.py", line 58, in write
im = self.generate_image(chars)
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\venv\lib\site-packages\captcha\image.py", line 228, in generate_image
im = self.create_captcha_image(chars, color, background)
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\venv\lib\site-packages\captcha\image.py", line 199, in create_captcha_image
images.append(_draw_character(c))
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\venv\lib\site-packages\captcha\image.py", line 165, in _draw_character
w, h = draw.textsize(c, font=font)
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\venv\lib\site-packages\PIL\ImageDraw.py", line 577, in textsize
return self.multiline_textsize(
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\venv\lib\site-packages\PIL\ImageDraw.py", line 601, in multiline_textsize
line_width, line_height = self.textsize(
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\venv\lib\site-packages\PIL\ImageDraw.py", line 583, in textsize
return font.getsize(text, direction, features, language, stroke_width)
File "G:\Programming\Python Projects\FREELANCING\TelegramBot\venv\lib\site-packages\PIL\ImageFont.py", line 421, in getsize
size, offset = self.font.getsize(text, "L", direction, features, language)
TypeError: expected string

Process finished with exit code -1


I have read all the items from this link!
What is the problem?

Captcha giving errors with new Pillow release

With new release of Pillow (ver 10) its giving
AttributeError: 'ImageDraw' object has no attribute 'textsize'
I tried using an older version of Pillow, but captcha by default downloads the latest version so you cant use it.

image

how can I generate a Blue fonts

        background = (0, 0, 255)  # random_color(238, 255)
        color = (0, 0, 255, 255) # random_color(0, 200, random.randint(220, 255))
        im = self.create_captcha_image(chars, color, background)
        #self.create_noise_dots(im, color)
        #self.create_noise_curve(im, color)
        im = im.filter(ImageFilter.SMOOTH)

When I set the 'color' Blue to 255(Red=0, Green=0), it seems that no use. The font is not blue.
Would you like help me. Thank your very much

TypeError when running image example

Trace:

......
data = image.generate('1234')
File "/usr/local/lib/python2.7/dist-packages/captcha/image.py", line 40, in generate
im = self.generate_image(chars)
File "/usr/local/lib/python2.7/dist-packages/captcha/image.py", line 219, in generate_image
self.create_noise_curve(im, color)
File "/usr/local/lib/python2.7/dist-packages/captcha/image.py", line 132, in create_noise_curve
Draw(image).arc(points, start, end, fill=color)
File "/usr/lib/python2.7/dist-packages/PIL/ImageDraw.py", line 164, in arc
self.draw.draw_arc(xy, start, end, ink)
TypeError: must be sequence of length 4, not 2

Auto widht

Can I auto-select the width so that the text fits completely into the picture? I found the text_width variable in your library, but I don't have access to it.

Relicense to GPL?

I like your project, but I think that it would serve a larger audience if it were explicitly licensed as GPLv3 code. Would you consider making this change?

image cut (missing/truncated letters)

hello,
i like this library a lot and i'm using it in my projects.
the only recurring problem i have is this:
sometimes (not very often, but also not very rarely), the generated captcha image cannot be fully read because the last letter is missing or truncated.
i tried with different combinations of fonts and number of characters, to set an acceptable wider static image width (250px for a 7 chars string) but that problem is still occuring.
sometimes, but more rarely, letters are also truncated on their lower part.
those problems happen when generated letters are too high, too wide or too spaced.

are you aware of that issue? any tip to fix or work around it?

thank you.

How to run test or demo?

I'm download in and install with command:

python setup.py install

It create folder lib, captcha.egg-info and dist.
I'm run captcha-master\build\lib\captcha with command:

python audio.py out.wav

But not show anything.

Thank you very much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.