Python 3.9 Errors with MKDocs Serve - python

After upgrading to Python 3.9, i'm getting these errors when running mkdocs serve I'm not a developer. I use MKDocs to build a documentation site and I wanted to upgrade the software, as a result I had to upgrade Python, pip, mkdocs and mkdocs-material..
INFO - Cleaning site directory
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 133, in serve_command
serve.serve(
File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 141, in serve
config = builder()
File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 136, in builder
build(config, live_server=live_server, dirty=dirty)
File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 263, in build
nav = get_navigation(files, config)
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 102, in get_navigation
items = _data_to_navigation(nav_config, files, config)
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 157, in _data_to_navigation
return [
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 158, in <listcomp>
_data_to_navigation(item, files, config)[0]
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 150, in _data_to_navigation
return [
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 153, in <listcomp>
Section(title=key, children=_data_to_navigation(value, files, config))
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 164, in _data_to_navigation
file = files.get_file_from_path(path)
File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/files.py", line 31, in get_file_from_path
return self.src_paths.get(os.path.normpath(path))
File "/usr/local/Cellar/python#3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/posixpath.py", line 336, in normpath
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType```

Try this.
pip install -U mkdocs
I was getting same error. After updated mkdocs it resolved.

Related

trying to run aws lambda locally with a layer for pandas using cdk - not working

I'm using the AWS CDK to run lambda functions locally. I have followed a couple of tutorials on setting this up but I appear to be getting issues when invoking the function with SAM. The typical error I encounter is below:
Invoking handler.handle (python3.9)
PypassLambdaLayer0643FC6D is a local Layer in the template
Image was not found.
Building image...Traceback (most recent call last):
File "runpy.py", line 194, in _run_module_as_main
File "runpy.py", line 87, in _run_code
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\__main__.py", line 12, in <module>
cli(prog_name="sam")
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 166, in wrapped
raise exception # pylint: disable=raising-bad-type
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 124, in wrapped
return_value = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\version_checker.py", line 41, in wrapped
actual_result = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\cli\main.py", line 87, in wrapper
return func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\invoke\cli.py", line 85, in cli
do_cli(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\invoke\cli.py", line 182, in do_cli
context.local_lambda_runner.invoke(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\lib\local_lambda.py", line 137, in invoke
self.local_runtime.invoke(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 230, in wrapped_func
return_value = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\lambdafn\runtime.py", line 177, in invoke
container = self.create(function_config, debug_context, container_host, container_host_interface)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\lambdafn\runtime.py", line 73, in create
container = LambdaContainer(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\lambda_container.py", line 93, in __init__
image = LambdaContainer._get_image(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\lambda_container.py", line 236, in _get_image
return lambda_image.build(runtime, packagetype, image, layers, architecture, function_name=function_name)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\lambda_image.py", line 163, in build
self._build_image(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\lambda_image.py", line 261, in _build_image
with create_tarball(tar_paths, tar_filter=tar_filter) as tarballfile:
File "contextlib.py", line 113, in __enter__
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\tar.py", line 29, in create_tarball archive.add(path_on_system, arcname=path_in_tarball, filter=tar_filter)
File "tarfile.py", line 1977, in add
File "tarfile.py", line 1977, in add
File "tarfile.py", line 1977, in add
[Previous line repeated 1 more time]
File "tarfile.py", line 1955, in add
File "tarfile.py", line 1834, in gettarinfo
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\LeeBarrett\\OneDrive - LumiraDx Group Ltd\\Documents\\pypass_dev\\2022\\pypass_connect_lambda\\cdk.out\\asset.60e64357ce064cf62274b8d1a8976ceb2903f31abd576090b450010d30b4ac7a\\python\\numpy\\.libs\\libopenblas.FB5AE2TYXYH2IJRDKGDGQ3XBKLKTF43H.gfortran-win_amd64.dll'
I've had multiple errors similar to that above but sometimes the file that is (apparently) missing is different. It looks like an issue with building the image rather than the stack code itself but I'm unsure and couldn't find any other similar issues.
The code I am using in the Stack class object is below:
pypass_lambda_layer = _lambda.LayerVersion(self, "PypassLambdaLayer", code=_lambda.Code.from_asset("lambda/layers"), compatible_runtimes=[_lambda.Runtime.PYTHON_3_9])
my_lambda = _lambda.Function(self, "Pypasshandler", runtime=_lambda.Runtime.PYTHON_3_9, code=_lambda.Code.from_asset("lambda/code"), handler="handler.handle", layers=[pypass_lambda_layer])
Tutorials I tried to follow:
https://dev.to/upupkenchoong/how-to-provision-lambda-and-lambda-layer-with-cdk-2ff4
https://medium.com/geekculture/deploying-aws-lambda-layers-with-python-8b15e24bdad2
The layers folder referenced in the LayerVersion function contains another folder called python which has pandas installed in it.
\lambda
\layers
\python
\code
handler.py
I'm on a windows machine and I have the cdk packages installed in conda virtual environment.
Any help would be greatly appreciated.
Thanks

Flask-Migrate cannot downgrade to a down_revision with merged heads

I have got this weird issue I ran into when downgrading my migration versions in Flask using Flask-Migrate.
I have this merged head revision which happened from branching and an alembic merge heads.
"""empty message
Revision ID: 3ad527666180
Revises: ecd1f453d08e, 7112dcc79711
Create Date: 2021-11-11 12:17:31.973196
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3ad527666180'
down_revision = ('7112dcc79711', 'ecd1f453d08e')
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass
When trying to downgrade to preceding revision which is 7112dcc79711, I get this error
docker exec -it users python manage.py db downgrade
/usr/local/lib/python3.7/site-packages/authlib/integrations/flask_oauth2/authorization_server.py:73: AuthlibDeprecationWarning: Define "get_jwt_config" in OpenID Connect grants
It will be compatible before version 1.0.
deprecate('Define "get_jwt_config" in OpenID Connect grants', '1.0')
/usr/local/lib/python3.7/site-packages/authlib/integrations/flask_oauth2/authorization_server.py:73: AuthlibDeprecationWarning: Define "get_jwt_config" in OpenID Connect grants
It will be compatible before version 1.0.
deprecate('Define "get_jwt_config" in OpenID Connect grants', '1.0')
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/alembic/script/base.py", line 227, in _catch_revision_errors
yield
File "/usr/local/lib/python3.7/site-packages/alembic/script/base.py", line 457, in _downgrade_revs
for script in revs
File "/usr/local/lib/python3.7/site-packages/alembic/script/base.py", line 454, in <listcomp>
migration.MigrationStep.downgrade_from_script(
File "/usr/local/lib/python3.7/site-packages/alembic/script/revision.py", line 798, in iterate_revisions
assert_relative_length=assert_relative_length,
File "/usr/local/lib/python3.7/site-packages/alembic/script/revision.py", line 1295, in _collect_downgrade_revisions
assert_relative_length=assert_relative_length,
File "/usr/local/lib/python3.7/site-packages/alembic/script/revision.py", line 1154, in _parse_downgrade_target
no_overwalk=assert_relative_length,
File "/usr/local/lib/python3.7/site-packages/alembic/script/revision.py", line 1069, in _walk
raise RevisionError("Ambiguous walk")
alembic.script.revision.RevisionError: Ambiguous walk
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 7, in <module>
cli()
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask/cli.py", line 380, in main
return AppGroup.main(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask/cli.py", line 257, in decorator
return __ctx.invoke(f, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask_migrate/cli.py", line 152, in downgrade
_downgrade(directory, revision, sql, tag, x_arg)
File "/usr/local/lib/python3.7/site-packages/flask_migrate/__init__.py", line 282, in downgrade
command.downgrade(config, revision, sql=sql, tag=tag)
File "/usr/local/lib/python3.7/site-packages/alembic/command.py", line 366, in downgrade
script.run_env()
File "/usr/local/lib/python3.7/site-packages/alembic/script/base.py", line 563, in run_env
util.load_python_file(self.dir, "env.py")
File "/usr/local/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 92, in load_python_file
module = load_module_py(module_id, path)
File "/usr/local/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 108, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "migrations/env.py", line 87, in <module>
run_migrations_online()
File "migrations/env.py", line 80, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/usr/local/lib/python3.7/site-packages/alembic/runtime/environment.py", line 851, in run_migrations
self.get_context().run_migrations(**kw)
File "/usr/local/lib/python3.7/site-packages/alembic/runtime/migration.py", line 608, in run_migrations
for step in self._migrations_fn(heads, self):
File "/usr/local/lib/python3.7/site-packages/alembic/command.py", line 355, in downgrade
return script._downgrade_revs(revision, rev)
File "/usr/local/lib/python3.7/site-packages/alembic/script/base.py", line 457, in _downgrade_revs
for script in revs
File "/usr/local/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.7/site-packages/alembic/script/base.py", line 261, in _catch_revision_errors
raise util.CommandError(err.args[0]) from err
alembic.util.exc.CommandError: Ambiguous walk
What is the safe way to get past this issue?
I have tried removing one of the revisions which come from a production branch, leaving the other which tallies with my development branch and it didn't produce the error.
Is there an automatic and more feasible way to just downgrade without this issue?
When I got such an error I tried to find another close revision that will work
In this case:
85c43587349b -> 69914284f0b4,
3a9ce166afbb -> 85c43587349b,
885269456833, 3a9ce166afbb -> a42162b3f858 (mergepoint)
3a9ce166afbb -> 885269456833,
f725b3be6238 -> 3a9ce166afbb (branchpoint)
6c164d07441f -> f725b3be6238
When I run alembic downgrade -1 it failed and also alembic downgrade f725b3be6238
But when I tried another version it worked
alembic downgrade 3a9ce166afbb

tuple index out of range (sqlfluff)

I am using python 3.9.1 and have 0.3.6 sqlfluff. I do lint some files successfully and fix them however I am trying to lint 757 rows of sql file and it is giving me this error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/bin/sqlfluff", line 8, in <module>
sys.exit(cli())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlfluff/cli/commands.py", line 172, in lint
result = lnt.lint_paths(paths, verbosity=verbose, ignore_non_existent_files=False)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlfluff/linter.py", line 911, in lint_paths
result.add(self.lint_path(path, verbosity=verbosity, fix=fix,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlfluff/linter.py", line 896, in lint_path
self.lint_string(target_file.read(), fname=fname,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlfluff/linter.py", line 748, in lint_string
lerrs, _, _, _ = crawler.crawl(parsed, dialect=config.get('dialect_obj'))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlfluff/rules/base.py", line 268, in crawl
dvs, raw_stack, child_fixes, memory = self.crawl(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlfluff/rules/base.py", line 233, in crawl
res = self._eval(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sqlfluff/rules/std.py", line 53, in _eval
if raw_stack[idx].type == 'whitespace':
IndexError: tuple index out of range
github issue

pytest KeyError: 'USER' within docker container

I am in the process of building a docker container that will run my automation tests. When I attempt to run the command below [this works locally and in jenkins] I get the following error:
root#645ed3930434:/test_dir# pytest test_* -m smoke
Traceback (most recent call last):
File "/usr/local/bin/pytest", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 49, in main
config = _prepareconfig(args, plugins)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 168, in _prepareconfig
pluginmanager=pluginmanager, args=args)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
return _wrapped_call(hook_impl.function(*args), self.execute)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
wrap_controller.send(call_outcome)
File "/usr/local/lib/python3.5/dist-packages/_pytest/helpconfig.py", line 68, in pytest_cmdline_parse
config = outcome.get_result()
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
raise ex[1].with_traceback(ex[2])
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
self.result = func()
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 957, in pytest_cmdline_parse
self.parse(args)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 1121, in parse
self._preparse(args, addopts=addopts)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 1084, in _preparse
self.pluginmanager.load_setuptools_entrypoints('pytest11')
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 516, in load_setuptools_entrypoints
self.register(plugin, name=ep.name)
File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 264, in register
ret = super(PytestPluginManager, self).register(plugin, name)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 371, in register
hook._maybe_apply_history(hookimpl)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 768, in _maybe_apply_history
res = self._hookexec(self, [method], kwargs)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/usr/local/lib/python3.5/dist-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/usr/local/lib/python3.5/dist-packages/pytest_cloud/plugin.py", line 76, in pytest_addoption
os.environ['USER'],
File "/usr/lib/python3.5/os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'USER'
I am new to docker, so I do not understand what is causing this error.
I am starting with a ubuntu as my base [this also happens when using a https://hub.docker.com/_/python/ as my base]
for reference requirements.txt includes the following:
apipkg==1.4
certifi==2017.11.5
chardet==3.0.4
execnet==1.5.0
idna==2.6
parameterized==0.6.1
psutil==5.4.1
py==1.5.2
pytest==3.2.5
pytest-cloud==2.0.0
pytest-forked==0.2
pytest-xdist==1.20.1
requests==2.18.4
six==1.11.0
timeout-decorator==0.4.0
urllib3==1.22
I have installed Python 3.5.2 in the container
The 'USER' environment variable seems not to defined within your image. Define it externally, or make your code resilient to its absence:
In your code, use os.getenv('USER', backup_user_name) instead of os.environ['USER']
In your code, use getpass instead of relying on your environment to get the current user.
import getpass
print getpass.getuser()
In docker run, you could add -e USER=$(whoami) or something of that sort
In docker-compose, you could add USER: some_user_name under the environ setting for that service.

Using pip install within PyScripter

I want to install a Python package within a script in PyScripter.
import pip
package = 'xlsxwriter'
pip.main(['install', package])
Following error occurs:
Collecting xlsxwriter
Downloading XlsxWriter-0.9.3-py2.py3-none-any.whl (136kB)
Exception:
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\commands\install.py", line 299, in run
requirement_set.prepare_files(finder)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\req\req_set.py", line 370, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\req\req_set.py", line 587, in _prepare_file
session=self.session, hashes=hashes)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\download.py", line 810, in unpack_url
hashes=hashes
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\download.py", line 649, in unpack_http_url
hashes)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\download.py", line 871, in _download_http_url
_download_url(resp, link, content_file, hashes)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\download.py", line 577, in _download_url
progress_indicator = DownloadProgressBar(max=total_length).iter
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\utils\ui.py", line 158, in __init__
super(WindowsMixin, self).__init__(*args, **kwargs)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\utils\ui.py", line 82, in __init__
super(InterruptibleMixin, self).__init__(*args, **kwargs)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\utils\ui.py", line 118, in __init__
super(DownloadProgressMixin, self).__init__(*args, **kwargs)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\_vendor\progress\helpers.py", line 58, in __init__
if self.file.isatty() and self.hide_cursor:
File "<string>", line 523, in __getattr__
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 150, in __getattr__
return syncreq(self, consts.HANDLE_GETATTR, name)
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 71, in syncreq
return conn.sync_request(handler, oid, *args)
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 434, in sync_request
raise obj
AttributeError: DebugOutput instance has no attribute 'isatty'
Why does this error occur und how to fix it? The same code works well when using the Python interpreter directly, but not with PyScripter for some reason.
Thanks a lot for your help.

Categories