Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i'm just so sure someone has already done this in python ... convert a number, at least an int, to its number name.
[numname(n) for n in range(5)] -> ['zero', 'one', 'two', 'three', 'four']
numname(18512) -> 'eighteen thousand five hundred twelve'
numname(-2000000000000) -> 'minus two trillion'
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 3,458
Threads: 101
Joined: Sep 2016
Not mine, but a quick google search found this: https://github.com/pwdyson/inflect.py
From the docs:
Quote: words = p.number_to_words(1234) # "one thousand, two hundred and thirty-four"
words = p.number_to_words(p.ordinal(1234)) # "one thousand, two hundred and thirty-fourth"
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i must have done something bad
Output: lt1/forums /home/forums 5> py3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inflect
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'inflect'
>>>
lt1/forums /home/forums 6> py2
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import inflect
>>>
lt1/forums /home/forums 7>
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 3,458
Threads: 101
Joined: Sep 2016
Looks like you installed the module for python2, not python3. Do you have a pip3 installed, that installs things for python3?
Posts: 7,320
Threads: 123
Joined: Sep 2016
As mention over you most install for python3(pip3).
Her a run in Mint-18.
mint@mint ~/Desktop/my_python $ virtualenv -p /usr/bin/python3.5 test
Running virtualenv with interpreter /usr/bin/python3.5
Using base prefix '/usr'
New python executable in /home/mint/Desktop/my_python/test/bin/python3.5
Also creating executable in /home/mint/Desktop/my_python/test/bin/python
Installing setuptools, pip, wheel...done.
mint@mint ~/Desktop/my_python $ cd test
mint@mint ~/Desktop/my_python/test $
mint@mint ~/Desktop/my_python/test $ source bin/activate
(test) mint@mint ~/Desktop/my_python/test $ pip3 install inflect
Collecting inflect
Downloading inflect-0.2.5-py2.py3-none-any.whl (58kB)
100% |████████████████████████████████| 61kB 1.5MB/s
Installing collected packages: inflect
Successfully installed inflect-0.2.5
(test) mint@mint ~/Desktop/my_python/test $ python
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
>>> import inflect
>>> p = inflect.engine()
>>> words = p.number_to_words(1234)
>>> words
'one thousand, two hundred and thirty-four'
>>> words = p.number_to_words(12345, group=1)
>>> words
'one, two, three, four, five'
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
Feb-17-2017, 09:52 AM
(This post was last modified: Feb-17-2017, 09:52 AM by Skaperen.)
i need to install pip3 i guess. neither pip nor pip3 are in ubuntu package repositories. i can't remember how i installed the original pip (it's'n /usr/local/bin ). there is no pip3 there. so i can't guess how to install pip3.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 2,953
Threads: 48
Joined: Sep 2016
Feb-17-2017, 10:05 AM
(This post was last modified: Feb-17-2017, 10:05 AM by wavic.)
Posts: 7,320
Threads: 123
Joined: Sep 2016
Feb-17-2017, 10:46 AM
(This post was last modified: Feb-17-2017, 10:46 AM by snippsat.)
(Feb-17-2017, 09:52 AM)Skaperen Wrote: so i can't guess how to install pip3. It should be sudo apt-get install python3-pip
Also virtual environment can be smart to use sudo pip install virtualenv
You see in my post that i make a environment with 3.5 and install inflect into it.
No need to install all into python system version.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
Feb-17-2017, 11:06 AM
(This post was last modified: Feb-17-2017, 11:06 AM by Skaperen.)
i found how pip was installed. i did Silly Walk dpkg -l|fgrep pip and it showed that the ubuntu package name was python-pip. that bumped my memory about how they name packages for python and i got a successful install of python3-pip ( not python3-pip3). now i am getting a new and bigger error:
Output: lt1/root /root 67# time logcmd -s pip3-upgrade pip3 install --upgrade pip3
Script started, file is ./20170217-050837-004340-pip3-upgrade.log
05:08:37 [4346] EXECUTING: 'pip3' 'install' '--upgrade' 'pip3'
Collecting pip3
Exception:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 377, in _make_request
httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 379, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.5/socket.py", line 575, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.5/ssl.py", line 929, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.5/ssl.py", line 791, in read
return self._sslobj.read(len, buffer)
File "/usr/lib/python3.5/ssl.py", line 575, in read
v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 560, in urlopen
body=body, headers=headers)
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 381, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 309, in _raise_timeout
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out. (read timeout=15)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 328, in run
wb.build(autobuilding=True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 748, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 360, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 512, in _prepare_file
finder, self.upgrade, require_hashes)
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 273, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/index.py", line 442, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3/dist-packages/pip/index.py", line 400, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python3/dist-packages/pip/index.py", line 545, in _get_pages
page = self._get_page(location)
File "/usr/lib/python3/dist-packages/pip/index.py", line 648, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python3/dist-packages/pip/index.py", line 757, in get_page
"Cache-Control": "max-age=600",
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 480, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/pip/download.py", line 378, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/adapter.py", line 46, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/adapters.py", line 376, in send
timeout=timeout
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 610, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 228, in increment
total -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[[ 0m16s real 16.648 - user 0.736 - sys 0.040 - 4.66% ]]
05:08:53 [4346] FINISHED - status = 2
Script done, file is ./20170217-050837-004340-pip3-upgrade.log
[[ 0m17s real 17.667 - user 0.736 - sys 0.040 - 4.39% ]]
lt1/root /root 68#
wow... 3 exceptions!!! anyone ever had anything like this, especially on ubuntu?
FYI: The logcmd command is my own ... not yet rewritten into Python. I plan for it to be Python 3 and hope to handle pty output directly It makes use of screen (which I hope to avoid in the Python 3 version)..
(Feb-17-2017, 10:05 AM)wavic Wrote: How about num2words
looks good to me. i like the many languages it supports and it might be fun to add more. it needs Swedish, Icelandic, Italian and Latin
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 2,953
Threads: 48
Joined: Sep 2016
You miss the Bulgarian
Strange error message. However, I've tried to install and use Ubuntu itself once. This kind of errors makes me crazy. I use Mint, Ubuntu MATE, Kubuntu or something else. Some CentOS based for instance.
Well, when you upgrade pip true pip I think it upgrades the both versions. It's how I interpret this:
victor@jerry:~$ sudo pip install -U pip
[sudo] password for victor:
Requirement already up-to-date: pip in /usr/local/lib/python3.5/dist-packages
|