Python PyDictionary Import error from futures - python

So I run python -m pip install PyDictionary and I get this output:
Collecting PyDictionary
Using cached PyDictionary-2.0.1-py3-none-any.whl (6.1 kB)
Requirement already satisfied: requests in d:\python\lib\site-packages (from PyDictionary) (2.27.1)
Collecting goslate
Using cached goslate-1.5.2.tar.gz (16 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: click in d:\python\lib\site-packages (from PyDictionary) (8.1.3)
Collecting bs4
Using cached bs4-0.0.1.tar.gz (1.1 kB)
Preparing metadata (setup.py) ... done
Collecting beautifulsoup4
Using cached beautifulsoup4-4.11.1-py3-none-any.whl (128 kB)
Requirement already satisfied: colorama in d:\python\lib\site-packages (from click->PyDictionary) (0.4.4)
Collecting futures
Using cached futures-3.0.5.tar.gz (25 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [27 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 14, in <module>
File "D:\Python\lib\site-packages\setuptools\__init__.py", line 189, in <module>
monkey.patch_all()
File "D:\Python\lib\site-packages\setuptools\monkey.py", line 99, in patch_all
patch_for_msvc_specialized_compiler()
File "D:\Python\lib\site-packages\setuptools\monkey.py", line 169, in patch_for_msvc_specialized_compiler
patch_func(*msvc14('_get_vc_env'))
File "D:\Python\lib\site-packages\setuptools\monkey.py", line 149, in patch_params
mod = import_module(mod_name)
File "D:\Python\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "D:\Python\lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 20, in <module>
import unittest.mock
File "D:\Python\lib\unittest\mock.py", line 26, in <module>
import asyncio
File "D:\Python\lib\asyncio\__init__.py", line 8, in <module>
from .base_events import *
File "D:\Python\lib\asyncio\base_events.py", line 18, in <module>
import concurrent.futures
File "C:\Users\localuser\AppData\Local\Temp\pip-install-vsl457j6\futures_9b56e18f578949cd955c2218e6840e1e\concurrent\futures\__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "C:\Users\localuser\AppData\Local\Temp\pip-install-vsl457j6\futures_9b56e18f578949cd955c2218e6840e1e\concurrent\futures\_base.py", line 357
raise type(self._exception), self._exception, self._traceback
^
SyntaxError: invalid syntax
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
How do I fix it so I can download PyDictionary.
I am using python 3.10.4.
I have saved Python onto a hard drive D: but it causes no other problems for pip.
The main problem I can see is that there is a problem importing Futures but from my research I have found that Futures is already downloaded for python 3 but when I try to uninstall it is says skipping as futures in not installed so maybe that is the problem but I don`t know how to solve it.
Anyone have any ideas?

This seems to be a known issue with this package. When issues like this occur, it is always best to go and check the official GitHub repository of the project and look through the open issues.
https://github.com/geekpradd/PyDictionary/issues/52#issuecomment-1105459595
I don't have any privileges on this repo. But I did some debugging I think the actual issue here is that goslate depends on futures, and futures >=3.0.0 isn't installable on python3 at all. The pypi page calls this out saying It does not work on Python 3 due to Python 2 syntax being used in the codebase. Python 3 users should not attempt to install it, since the package is already included in the standard library. -- https://pypi.org/project/futures/
I am able to work around the issue by installing futures <3.0.0 before installing PyDictionary:

Try this method but it is giving few results only. This library uses dictionary.com
pip install Py-Dictionary
from pydictionary import Dictionary
dict = Dictionary("lastname")
To store it somewhere in a variable
meanings_list = dict.meanings()
synonyms_list = dict.synonyms()
antonyms_list = dict.antonyms()
To print this
dict.print_meanings()
dict.print_synonyms()
dict.print_antonyms()

Related

No module named 'gensim' in AWS Glue

I am trying to use Gensim in AWS Glue ETL job. I have created and tested the gensim wheel in sagemaker and it appears to be working correctly. I have added the wheel file in S3 and added the path in the "Python library path" in glue job details. Still the glue script fails with gensim not found error.
Gensim setup.py file
from setuptools import setup
setup(
name="gensim",
version="4.1.0",
packages=['gensim'],
install_requires=['Cython', 'numpy', 'scipy', 'smart-open']
)
After creating the wheel file, I tested it and it installed gensim properly.
sh-4.2$ pip install dist/gensim-4.1.0-py3-none-any.whl
Processing ./dist/gensim-4.1.0-py3-none-any.whl
Requirement already satisfied: Cython in /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/Cython-3.0.0a11-py3.7.egg (from gensim==4.1.0) (3.0.0a11)
Requirement already satisfied: smart-open in /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/smart_open-6.2.0-py3.7.egg (from gensim==4.1.0) (6.2.0)
Requirement already satisfied: numpy in /home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages (from gensim==4.1.0) (1.21.6)
Requirement already satisfied: scipy in /home/ec2-user/.local/lib/python3.7/site-packages (from gensim==4.1.0) (1.7.3)
Installing collected packages: gensim
Successfully installed gensim-4.1.0
Glue job output logs show that it is installed properly
2022-09-28T18:33:40.657+05:30 Processing ./glue-python-libs-rutqf0ex/gensim-4.1.0-py3-none-any.whl
2022-09-28T18:33:40.730+05:30 Collecting smart-open
2022-09-28T18:33:40.749+05:30 Downloading smart_open-6.2.0-py3-none-any.whl (58 kB)
2022-09-28T18:33:41.500+05:30 Collecting Cython
2022-09-28T18:33:41.508+05:30 Downloading Cython-0.29.32-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (2.0 MB)
2022-09-28T18:33:42.216+05:30 Collecting numpy
2022-09-28T18:33:42.221+05:30 Downloading numpy-1.19.5-cp36-cp36m-manylinux2010_x86_64.whl (14.8 MB)
2022-09-28T18:33:43.126+05:30 Collecting scipy
2022-09-28T18:33:43.143+05:30 Downloading scipy-1.5.4-cp36-cp36m-manylinux1_x86_64.whl (25.9 MB)
2022-09-28T18:33:44.258+05:30 Installing collected packages: smart-open, Cython, numpy, scipy, gensim
2022-09-28T18:33:49.744+05:30
Copy
Successfully installed Cython-0.29.32 gensim-4.1.0 numpy-1.19.5 scipy-1.5.4 smart-open-6.2.0
Successfully installed Cython-0.29.32 gensim-4.1.0 numpy-1.19.5 scipy-1.5.4 smart-open-6.2.0
2022-09-28T18:33:53.981+05:30 Processing ./glue-python-libs-rutqf0ex/bio-1.3.9-py3-none-any.whl
Glue job error
ModuleNotFoundError: No module named 'gensim'
I came across these two errors in the glue error log.
ERROR: botocore 1.12.232 has requirement urllib3<1.26,>=1.20; python_version >= "3.4", but you'll have urllib3 1.26.12 which is incompatible.
Traceback (most recent call last):
File "/tmp/runscript.py", line 211, in <module>
runpy.run_path(temp_file_path, run_name='__main__')
File "/usr/local/lib/python3.6/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "/usr/local/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/glue-python-scripts-cr7714l4/train-lda-model.py", line 11, in <module>
ModuleNotFoundError: No module named 'gensim'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/runscript.py", line 230, in <module>
raise e_type(e_value).with_traceback(new_stack)
File "/tmp/glue-python-scripts-cr7714l4/train-lda-model.py", line 11, in <module>
ModuleNotFoundError: No module named 'gensim'
Since "gensim" is a custom library you need to pack the dependency as a zip file, uploading it to s3 and indicate the s3 path in the Glue job param called "Python library path". AWS Documentation

Why do I install ffmpeg-python error via pip, python on version 3.9.13 and pip on version 22.2.1

$ pip3 install ffmpeg-python
Collecting ffmpeg-python
Using cached ffmpeg_python-0.2.0-py3-none-any.whl (25 kB)
Collecting future
Downloading future-0.18.2.tar.gz (829 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 829.2/829.2 kB 5.2 MB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 14, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 14, in <module>
from setuptools.dist import Distribution, Feature
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 24, in <module>
from setuptools.depends import Require
File "/usr/lib/python3/dist-packages/setuptools/depends.py", line 7, in <module>
from .py33compat import Bytecode
File "/usr/lib/python3/dist-packages/setuptools/py33compat.py", line 54, in <module>
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
enter image description here
It is working for me.
Python version - 3.7.1,
pip version - 22.1.2

Getting error while installing 'formatter' module

I am trying to install formatter using,
pip install formatter
but it throws the following error,
Collecting formatter
Using cached formatter-1.0.3.tar.gz (17 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [10 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/2b/x_hy0wt13mgcbznrm263kzmr0000gr/T/pip-install-l76arg1s/formatter_b9bbf1e04d7a4bda8f51556e744f0357/setup.py", line 2, in <module>
import formatter as metadata
File "/private/var/folders/2b/x_hy0wt13mgcbznrm263kzmr0000gr/T/pip-install-l76arg1s/formatter_b9bbf1e04d7a4bda8f51556e744f0357/formatter/__init__.py", line 9, in <module>
from .formatter import Formatter
File "/private/var/folders/2b/x_hy0wt13mgcbznrm263kzmr0000gr/T/pip-install-l76arg1s/formatter_b9bbf1e04d7a4bda8f51556e744f0357/formatter/formatter.py", line 4, in <module>
from cStringIO import StringIO
ModuleNotFoundError: No module named 'cStringIO'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
I tried installing cStringIO but it throws another error,
ERROR: Could not find a version that satisfies the requirement cStringIO (from versions: none)
ERROR: No matching distribution found for cStringIO
Can anyone help me ?
This package was removed from python 3.10 (see latest doc from 3.9). You should update the code to not use the formatter module.

What does this traceback error mean when running this python script in Anaconda?

New to programming. Installed Anaconda on a Windows 10 machine. Had some issues running updates.
While in Base environment, I installed my first Git repo successfully:
(base) C:\Users\samsung\Anaconda3\pkgs>pip install git+git://github.com/json-transformations/jsonflatten.git
Collecting git+git://github.com/json-transformations/jsonflatten.git
Cloning git://github.com/json-transformations/jsonflatten.git to c:\users\samsung\appdata\local\temp\pip-req-build-zeiezw
Running command git clone -q git://github.com/json-transformations/jsonflatten.git 'C:\Users\samsung\AppData\Local\Temp\p
Collecting jsoncut
Downloading jsoncut-0.6-py2.py3-none-any.whl (17 kB)
Requirement already satisfied: click>=6.0 in c:\users\samsung\anaconda3\lib\site-packages (from jsonflatten==0.2) (7.0)
Requirement already satisfied: colorama in c:\users\samsung\anaconda3\lib\site-packages (from jsoncut->jsonflatten==0.2) (0
Requirement already satisfied: pygments in c:\users\samsung\anaconda3\lib\site-packages (from jsoncut->jsonflatten==0.2) (2
Building wheels for collected packages: jsonflatten
Building wheel for jsonflatten (setup.py) ... done
Created wheel for jsonflatten: filename=jsonflatten-0.2-py2.py3-none-any.whl size=8116 sha256=029aafde944303cbfe872e86a13
Stored in directory: C:\Users\samsung\AppData\Local\Temp\pip-ephem-wheel-cache-so8173tt\wheels\8f\02\52\37295acfd1368a3d2
Successfully built jsonflatten
Installing collected packages: jsoncut, jsonflatten
Successfully installed jsoncut-0.6 jsonflatten-0.2
(base) C:\Users\samsung\Anaconda3\pkgs>pip install jsonflatten
Requirement already satisfied: jsonflatten in c:\users\samsung\anaconda3\lib\site-packages (0.2)
Requirement already satisfied: click>=6.0 in c:\users\samsung\anaconda3\lib\site-packages (from jsonflatten) (7.0)
Requirement already satisfied: jsoncut in c:\users\samsung\anaconda3\lib\site-packages (from jsonflatten) (0.6)
Requirement already satisfied: pygments in c:\users\samsung\anaconda3\lib\site-packages (from jsoncut->jsonflatten) (2.5.2)
Requirement already satisfied: colorama in c:\users\samsung\anaconda3\lib\site-packages (from jsoncut->jsonflatten) (0.4.3)
I then ran jsonflatten forecast.json as a test (as well as jsonflatten C:\Users\samsung.spyder-py3\forecast.json) as the readme suggests and got the output below. I ran from base as myenv (Python) spit out a message saying jsonflatten is not recognized as a command.
(base) C:\Users\samsung\.spyder-py3>jsonflatten C:\Users\samsung\.spyder-py3\forecast.json
Traceback (most recent call last):
File "c:\users\samsung\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\samsung\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\samsung\Anaconda3\Scripts\jsonflatten.exe\__main__.py", line 7, in <module>
File "c:\users\samsung\anaconda3\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\users\samsung\anaconda3\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\samsung\anaconda3\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\samsung\anaconda3\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\samsung\anaconda3\lib\site-packages\click\decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\users\samsung\anaconda3\lib\site-packages\jsonflatten\cli.py", line 63, in main
output(ctx, results, indent=4, is_json=True)
File "c:\users\samsung\anaconda3\lib\site-packages\jsoncut\cli.py", line 59, in output
output = highlighter.highlight_json(output)
File "c:\users\samsung\anaconda3\lib\site-packages\jsoncut\highlighter.py", line 53, in highlight_json
return pygments.highlight(d, JsonLexer(), formatter)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\__init__.py", line 85, in highlight
return format(lex(code, lexer), formatter, outfile)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\__init__.py", line 64, in format
formatter.format(tokens, realoutfile)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\formatters\terminal.py", line 101, in format
return Formatter.format(self, tokensource, outfile)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\formatter.py", line 95, in format
return self.format_unencoded(tokensource, outfile)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\formatters\terminal.py", line 126, in format_unencoded
outfile.write(ansiformat(color, line.rstrip('\n')))
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\console.py", line 68, in ansiformat
result.append(codes[attr])
KeyError: 'darkgray'
There is a guide for troubleshooting software in Anaconda: https://www.anaconda.com/what-to-do-when-things-go-wrong-in-anaconda/ but this is a brand-new install.
Does this look like an Anaconda issue, an issue with how I am running the software or an issue with the software itself?
You're getting an error in site-packages with a module that is a dependency of something that you've installed.
Anaconda is just a distribtion, not the runtime.
The problem is from Python's pygments\console.py module, which is likely responsible for coloring the output of your jsonflatten module.
Try to see if there is a CLI flag to not colorize stuff, or don't use jsonflatten and rather use python's json.tool or separately install jq instead. (not saying those offer what you need, but they also parse JSON on the CLI)

Attribute error on python WebUI installation

I am trying to install WebUI using pip install WebUI and I got this error
Collecting WebUI
Using cached https://files.pythonhosted.org/packages/45/06/5f4ddb9a5d4acf9600be3a794bee670f778e43bbcd648e3f58cc8326cd6a/WebUI-0.1.7.zip
Collecting Flask==0.10.1 (from WebUI)
Using cached https://files.pythonhosted.org/packages/db/9c/149ba60c47d107f85fe52564133348458f093dd5e6b57a5b60ab9ac517bb/Flask-0.10.1.tar.gz
Collecting Jinja2==2.7.1 (from WebUI)
Using cached https://files.pythonhosted.org/packages/47/83/679b5592feb54e948d6599edf5dac61d2991778c3ecbef6b8041663f4740/Jinja2-2.7.1.tar.gz
Collecting MarkupSafe==0.18 (from WebUI)
Using cached https://files.pythonhosted.org/packages/98/cf/197c3b0f73224b84eb419a967f87565bcc0b0c1147012397e6bd2d45e253/MarkupSafe-0.18.tar.gz
Collecting Werkzeug==0.9.4 (from WebUI)
Using cached https://files.pythonhosted.org/packages/d8/5e/8abc95630f9c4248edffed30592468f884e845ba656a959a12e452fafcec/Werkzeug-0.9.4.tar.gz
Collecting itsdangerous==0.23 (from WebUI)
Using cached https://files.pythonhosted.org/packages/c1/6c/ceefb52b2a5d7d1f2b1b407a96892182161904478b9ef86049e7b8162cb6/itsdangerous-0.23.tar.gz
Collecting pyside==1.2.1 (from WebUI)
Using cached https://files.pythonhosted.org/packages/f1/32/63872fdc1d9e0de5aa0b05b9d1a17d868851c619cdc6998dd9d853556f1b/PySide-1.2.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\RBCABR~1\AppData\Local\Temp\pip-install-546zsn2s\pyside\setup.py", line 82, in <module>
from utils import rmtree
File "C:\Users\RBCABR~1\AppData\Local\Temp\pip-install-546zsn2s\pyside\utils.py", line 10, in <module>
import popenasync
File "C:\Users\RBCABR~1\AppData\Local\Temp\pip-install-546zsn2s\pyside\popenasync.py", line 26, in <module>
if subprocess.mswindows:
AttributeError: module 'subprocess' has no attribute 'mswindows'
can someone explain the reason for this error and how to fix this?

Categories