Streamlit install fails on GitLab CI with UnicodeEncodeError - unicode

On GitLab CI, after upgrading streamlit to 1.10.0, I have the following error while running pip install streamlit:
ERROR: Exception:
Traceback (most recent call last):
File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
status = run_func(*args)
File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
return func(self, options, args)
File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 413, in run
pycompile=options.compile,
File "/builds/lproject/venv/lib/python3.6/site-packages/pip/_internal/req/__init__.py", line 81, in install_given_reqs
pycompile=pycompile,
File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 810, in install
requested=self.user_supplied,
File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 737, in install_wheel
requested=requested,
File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 589, in _install_wheel
file.save()
File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 383, in save
if os.path.exists(self.dest_path):
File "/builds/project/venv/lib/python3.6/genericpath.py", line 19, in exists
os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f4f9' in position 76: ordinal not in range(128)
I checked the faulty encoded character and it corresponds to the video camera emoji 📹 = \U0001f4f9.
How can I solve it?

The bug has been introduced by Streamlit 1.10.0. The video camera emoji has been added to the streamlit hello command after the introduction of the multi-page feature: https://github.com/streamlit/streamlit/tree/release/1.10.0/lib/streamlit/hello/pages
In my CI, the encodings were the following:
$ locale || true
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
I reset them using:
before_script:
- apt-get install -y locales
- echo "en_US UTF-8" > /etc/locale.gen
- locale-gen en_US.UTF-8
- export LANG=en_US.UTF-8
- export LANGUAGE=en_US:en
- export LC_ALL=en_US.UTF-8
and now it works.
Thanks to Bill's answer.

Related

Sagemath Jupyter Kernel install error after conda-forge installation

So I've installed SageMath through anaconda with conda install sage python jupyterlab.
I then go to install the sage jupyter kernel as in this thread via jupyter kernelspec install --user ~/miniconda3/envs/sage/share/jupyter/kernels/sagemath
But this command fails with the following error
Traceback (most recent call last):
File "/Users/llamagod/miniconda3/envs/sage/bin/jupyter-kernelspec", line 10, in <module>
sys.exit(KernelSpecApp.launch_instance())
File "/Users/llamagod/miniconda3/envs/sage/lib/python3.9/site-packages/traitlets/config/application.py", line 845, in launch_instance
app.start()
File "/Users/llamagod/miniconda3/envs/sage/lib/python3.9/site-packages/jupyter_client/kernelspecapp.py", line 266, in start
return self.subapp.start()
File "/Users/llamagod/miniconda3/envs/sage/lib/python3.9/site-packages/jupyter_client/kernelspecapp.py", line 132, in start
self.kernel_spec_manager.install_kernel_spec(self.sourcedir,
File "/Users/llamagod/miniconda3/envs/sage/lib/python3.9/site-packages/jupyter_client/kernelspec.py", line 340, in install_kernel_spec
shutil.copytree(source_dir, destination)
File "/Users/llamagod/miniconda3/envs/sage/lib/python3.9/shutil.py", line 557, in copytree
return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
File "/Users/llamagod/miniconda3/envs/sage/lib/python3.9/shutil.py", line 513, in _copytree
raise Error(errors)
shutil.Error: [('/Users/llamagod/miniconda3/envs/sage/share/jupyter/kernels/sagemath/doc', '/Users/llamagod/Library/Jupyter/kernels/sagemath/doc', "[Errno 2] No such file or directory: '/Users/llamagod/miniconda3/envs/sage/share/jupyter/kernels/sagemath/doc'")]
I tried symlinking $SAGE_LOCAL/share/doc to that directory but I get the same error.
SageMath 9.2, JupyterLab 3.0.16
Is this a known issue ?
In the end I used the alternate method described on this page to install the kernel and avoid copying over the documentation.
ln -s `sage -sh -c 'ls -d $SAGE_LOCAL/share/jupyter/kernels/sagemath'` $HOME/miniconda3/envs/sage/share/jupyter
So I can now run the sagemath kernel from the jupyter in my conda environment.

Unable to use jsonpath_rw_ext with pyspark

These are the steps I am following:
mkdir spark_lib; cd spark_lib
pip install jsonpath_rw_ext==1.1.3 -t .
zip -r9 ../spark_lib.zip *
Initialize spark context variable sc
sc.addPyFile('spark_lib.zip')
def f(x):
import jsonpath_rw_ext
return jsonpath_rw_ext.match('$.a.b', x)
sc.parallelize([{"a":{"b":10}}]).map(f).collect()
This gives me a pbr versioning error
File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 268, in dump_stream
vs = list(itertools.islice(iterator, batch))
File "<ipython-input-11-2619fc011e24>", line 6, in f
File "./spark_lib.zip/jsonpath_rw_ext/__init__.py", line 18, in <module>
File "./spark_lib.zip/pbr/version.py", line 467, in version_string
return self.semantic_version().brief_string()
File "./spark_lib.zip/pbr/version.py", line 462, in semantic_version
self._semantic = self._get_version_from_pkg_resources()
File "./spark_lib.zip/pbr/version.py", line 449, in _get_version_from_pkg_resources
result_string = packaging.get_version(self.package)
File "./spark_lib.zip/pbr/packaging.py", line 824, in get_version
name=package_name))
Exception: Versioning for this project requires either an sdist tarball,
or access to an upstream git repository. It's also possible that
there is a mismatch between the package name in setup.cfg
and the argument given to pbr.version.VersionInfo.
Project name jsonpath_rw_ext was given, but was not able to be found.
After reading through another similar bug https://bugs.launchpad.net/python-swiftclient/+bug/1379579, found out that pbr needs updated setuptools.
I included setuptools in my pip installation command and everything worked fine.
pip install jsonpath_rw_ext setuptools -t .

Pip installing kerosene gives unicodeDecodeError

I'm trying to execute pip3 install kerosene from a nvidia-docker container. I get the error:
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-16cx_v3e/fuel/setup.py", line 10, in <module>
LONG_DESCRIPTION = f.read().strip()
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1803: ordinal not in range(128)
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-0e0cswbo/fuel/
I googled this error and saw that some people got it from having non-ascii characters in working directory or username, but I don't think this is the case for me. Does anybody know a fix or how I can look into this further?
The bug seems to be fixed in fuel 2 years ago but it's not included in the package at PyPI. Install from Github:
pip install -U git+https://github.com/mila-udem/fuel.git#egg=fuel

Pyephem failing to install after "Cleanup" stage

I ran pip install pyephem, and all text is white, then I get a white "Cleaning up...", followed by red text that reads
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-eG5Kab/pyephem/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-LWQvRn-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-eG5Kab/pyephem
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 248, in main
return command.main(cmd_args)
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 40: ordinal not in range(128)
What do I need to do here?
Figured it out myself. Needed to use pip3 install pyephem instead, since I'm using Python 3. Sorry for wasting everyone's time!

Trying to Install AWS CLI, stuck on a step

Im trying to install aws for the mac command line, I guess I dont understand what I need to do I installed the aws bundle with wget on the terminal, unziped it did everything, but when I need to configure my credentials nothing comes up when I put aws configure..
Here are the Instructions:
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html
Here is what is ouputed
an$ aws configuration
Traceback (most recent call last):
File "/usr/local/bin/aws", line 15, in <module>
import awscli.clidriver
File "/usr/local/aws/lib/python2.7/site-packages/awscli/clidriver.py", line 31, in <module>
from awscli.help import ProviderHelpCommand
File "/usr/local/aws/lib/python2.7/site-packages/awscli/help.py", line 20, in <module>
from docutils.core import publish_string
File "/usr/local/aws/lib/python2.7/site-packages/docutils/core.py", line 20, in <module>
from docutils import frontend, io, utils, readers, writers
File "/usr/local/aws/lib/python2.7/site-packages/docutils/frontend.py", line 41, in <module>
import docutils.utils
File "/usr/local/aws/lib/python2.7/site-packages/docutils/utils/__init__.py", line 20, in <module>
import docutils.io
File "/usr/local/aws/lib/python2.7/site-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/usr/local/aws/lib/python2.7/site-packages/docutils/utils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/usr/local/aws/lib/python2.7/locale.py", line 511, in getdefaultlocale
return _parse_localename(localename)
File "/usr/local/aws/lib/python2.7/locale.py", line 443, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
Any Ideas_?
try adding below lines to ~/.bash_profile:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Installing AWSCLI in Windows Machine
I had similar issue with Windows 10 (64 bit). Python 3.5 and Python 2.7 are installed in my PC. I was getting ImportError: No module named awscli.clidriver.
Then I added %USERPROFILE%\AppData\Roaming\Python\Python35\Scripts in environment path variable and removed Python 2.7 from the environment path variable. Now I can successfully use awscli.
I have created a step by step AWSCLI installation guide in this Github repository: https://github.com/arsho/installation/tree/master/awscli_installation.
I had to install EKS supported version and I ended up getting it to work with ignoring six:
$ pip3 install awscli --ignore-installed six
In my case nothing worked, untill i gave more permissions, i run aws command with a non root user
chown amzadm.root /usr/bin/aws
chown amzadm.root -R /usr/lib/python2.6/site-packages/
chown amzadm.root -R /usr/lib/python2.6/site-packages/awscli/
I fixed this by adding a line to the 'aws' script just before the import (line 19). So now the file reads:
sys.path.append('/Users/<username>/.local/lib/aws/lib/python2.7/site-packages/')
import awscli.clidriver
This work for me. In /.barshrc file
export AWS_DEFAULT_OUTPUT="json"