Jupyter with docker: __init__() got an unexpected keyword argument 'column' - python

I recently installed TensorFlow with GPU support using docker:
docker pull tensorflow/tensorflow:latest-gpu-jupyter
But sometimes when I start a jupyter notebook server using the command:
docker run --gpus all -it -p 8888:8888 tensorflow/tensorflow:latest-gpu-jupyter jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --allow-root --NotebookApp.allow_origin='https://colab.research.google.com'
I see the following exception on the terminal:
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 272, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))
File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 762, in run
value = future.result()
File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 234, in wrapper
yielded = ctx_run(next, result)
File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 162, in _fake_ctx_run
return f(*args, **kw)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 580, in complete_request
matches = yield gen.maybe_future(self.do_complete(code, cursor_pos))
File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 348, in do_complete
return self._experimental_do_complete(code, cursor_pos)
File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 373, in _experimental_do_complete
completions = list(_rectify_completions(code, raw_completions))
File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 484, in rectify_completions
completions = list(completions)
File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 1818, in completions
for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 1862, in _completions
full_text=full_text, cursor_line=cursor_line, cursor_pos=cursor_column)
File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 2030, in _complete
cursor_pos, cursor_line, full_text)
File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 1374, in _jedi_matches
text[:offset], namespaces, column=cursor_column, line=cursor_line + 1)
File "/usr/local/lib/python3.6/dist-packages/jedi/api/__init__.py", line 726, in __init__
project=Project(Path.cwd()), **kwds)
TypeError: __init__() got an unexpected keyword argument 'column'
After that, I have to restart the server or reconnect from google colab.
Any ideas where the error might come from and how to fix it?

This seems to be an incompatibility between jedi and ipython, see this issue.
The fix would be to pin jedi to 0.17.2, so either run:
pip install jedi==0.17.2
Or if you are using poetry add this to your pyproject.toml:
jedi = "<=0.17.2"
But since you are using a docker image that image will need to be updated. It seems to be gpu-jupyter.Dockerfile.
I would raise an issue on that project and see if they can pin jedi like they did for nbformat, or you could just fork it. They should probably upgrade python as well, 3.6 is getting a bit long in the tooth.

I will add more details to #daphtdazz's answer. I had to do the following steps to solve this issue:
1. Download TensorFlow from github:
git clone https://github.com/tensorflow/tensorflow.git
2. Edit the file gpu-jupyter.Dockerfile to add jedi==0.17.2 at the end of line 104:
vim tensorflow/tensorflow/tools/dockerfiles/dockerfiles/gpu-jupyter.Dockerfile
3. Placed myself inside the dockerfiles folder :
cd tensorflow/tensorflow/tools/dockerfiles/
4. Build the image:
docker build -f ./dockerfiles/gpu-jupyter.Dockerfile -t tf .

Related

pip install fails with TypeError: identify() got an unexpected keyword argument 'requirement_or_candidate'

i have recently moved my arch linux installation to a new machine using a bottom to top approach. I.e. new install of arch linux, reinstallation of all packages and then copying selected configs to the new machine.
Now when I try to install a program with pip, I get a TypeError like so:
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 224, in _main
status = self.run(options, args)
File "/usr/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
return func(self, options, args)
File "/usr/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 320, in run
requirement_set = resolver.resolve(
File "/usr/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 121, in resolve
self._result = resolver.resolve(
File "/home/mor3dr3ad/.local/lib/python3.9/site-packages/resolvelib/resolvers.py", line 454, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "/home/mor3dr3ad/.local/lib/python3.9/site-packages/resolvelib/resolvers.py", line 319, in resolve
name, crit = self._merge_into_criterion(r, parent=None)
File "/home/mor3dr3ad/.local/lib/python3.9/site-packages/resolvelib/resolvers.py", line 171, in _merge_into_criterion
name = self._p.identify(requirement_or_candidate=requirement)
TypeError: identify() got an unexpected keyword argument 'requirement_or_candidate'
Installing as root via sudo actually works (I know I should not be doing this, just for testing. So I am thinking that it must be due to a permission issue or missing something in terms of groups.
Can anybody point me in the right direction? Do I need to add my user to a certain group?
Thank you
You have a locally installed library resolvelib at /home/mor3dr3ad/.local/lib/python3.9/site-packages/resolvelib/. It seems it's incompatible with pip vendored resolvelib at /usr/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/ and /usr/lib/python3.9/site-packages/pip/_vendor/resolvelib/.
My advice is to uninstall local resolvelib. Try
pip uninstall resolvelib
PS. Most probably sudo works because it switches the user to root and the user doesn't have local packages at /root/.local/lib/

Installing Google Cloud SDK throwing error in install.py when using install.bat

I am trying to install google cloud SDK using install.bat. I have tried downloading the bundled pythons versions 275 and current version 276, they both fail at the same spot. It is able to find python in the platform/bundledpython folder so that is not the issue. I have also tried the suggestions online including making sure that the "Find" command works on a command prompt. Any help appreciated.
The latest available version is: 276.0.0
���───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐Trac
back (most recent call last):
File "C:\google-cloud-sdk\google-cloud-sdk\\bin\bootstrapping\install.py", line 225, in <module>
main()
File "C:\google-cloud-sdk\google-cloud-sdk\\bin\bootstrapping\install.py", line 203, in main
Install(pargs.override_components, pargs.additional_components)
File "C:\google-cloud-sdk\google-cloud-sdk\\bin\bootstrapping\install.py", line 148, in Install
_CLI.Execute(['--quiet', 'components', 'list'])
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 1007, in Execute
self._HandleAllErrors(exc, command_path_string, specified_arg_names)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 1040, in _HandleAllErrors
exceptions.HandleError(exc, command_path_string, self.__known_error_handler)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\exceptions.py", line 527, in HandleError
core_exceptions.reraise(exc)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\exceptions.py", line 146, in reraise
six.reraise(type(exc_value), exc_value, tb)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 981, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 809, in Run
display_info=self.ai.display_info).Display()
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\display.py", line 483, in Display
self._printer.Print(self._resources)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\resource\resource_printer_base.py", line 279, in P
int
self.Finish()
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\resource\table_printer.py", line 467, in Finish
self._out.write(line)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\log.py", line 239, in write
self._Write(plain_text, styled_text)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\log.py", line 232, in _Write
self.__stream_wrapper.stream.write(stream_msg)
I just had the same problem trying to install the latest Google Cloud SDK (276.0.0). The Windows setup was stuck on "Installing components".
Looking at the process list with Process Explorer I could see it was running this command that was stuck, as you probably did to get your stack trace. I took the command line and ran it in a separate Administror cmd.exe (paths might differ per system, the idea is the same).
cd "C:\Program Files (x86)\Google\Cloud SDK"
SET "CLOUDSDK_CORE_DISABLE_PROMPTS=1"
SET "CLOUDSDK_CONFIG=%APPDATA%\gcloud"
"C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\install.bat" --quiet --disable-installation-options --path-update "FALSE" --usage-reporting "true" --additional-components beta powershell"
Running them would produce the same error / stack trace.
Editing log.py and commenting out (prefix with #) line 232 would make it get further, but it runs into a separate problem:
ERROR: Cannot use bundled Python installation to update Cloud SDK in non-interactive mode.
Please run again in interactive mode.
Enable prompts with CLOUDSDK_CORE_DISABLE_PROMPTS envvar and remove --quiet and --disable-installation-options from the install.bat command line and run it again.
SET "CLOUDSDK_CORE_DISABLE_PROMPTS=0"
"C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\install.bat" --path-update "FALSE" --usage-reporting "true" --additional-components beta powershell"
This time it should continue, start a new console where it actually installs the components and eventually finish succesfully.

Alembic error on Heroku: Can't find Python file migrations/env.py

Trying to deploy a Flask app on Heroku, used to work perfectly with other apps, but now when I try to upgrade the db with:
>:heroku run python manage.py db upgrade
I get the following error:
Traceback (most recent call last):
File "manage.py", line 121, in <module>
manager.run()
File "/app/.heroku/python/lib/python3.6/site-packages/flask_script/__init__.py", line 417, in run
result = self.handle(argv[0], argv[1:])
File "/app/.heroku/python/lib/python3.6/site-packages/flask_script/__init__.py", line 386, in handle
res = handle(*args, **config)
File "/app/.heroku/python/lib/python3.6/site-packages/flask_script/commands.py", line 216, in __call__
return self.run(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/flask_migrate/__init__.py", line 259, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/app/.heroku/python/lib/python3.6/site-packages/alembic/command.py", line 254, in upgrade
script.run_env()
File "/app/.heroku/python/lib/python3.6/site-packages/alembic/script/base.py", line 425, in run_env
util.load_python_file(self.dir, 'env.py')
File "/app/.heroku/python/lib/python3.6/site-packages/alembic/util/pyfiles.py", line 85, in load_python_file
raise ImportError("Can't find Python file %s" % path)
ImportError: Can't find Python file migrations/env.py
The file migrations/env.py is there on my local machine, and in the git repository:
>: git status migrations\env.py
On branch master
nothing to commit, working tree clean
Locally I work on python 3.6.3, tried also to move to python 3.6.4 on Heroku because it says 3.6.3 is not supported, but with no luck.
Locally, it works without problem, I can migrate and upgrade the DB (postgres both locally and on heroku).
Thanks
This happened to me !
Here is how I solved the problem:
I logged into my dyno using
heroku ps:exec
Then I went to my migrations folder, and the env.py was not there.
So I checked my .gitignore, and there was obviously a env* line in it.
So just delete this line, and commit your migrations/env.py on Heroku.
Try to init it first.I also encountered this problem when I implemented the examples in the book.Then I noticed that I had missed initalization.

IOError: [Errno 0] Error while writing to output of Powershell in VSCode

This is the error I get in VSCode when running docker-compose.
PS D:\Work\Imho\Api> docker-compose -f docker-compose.yml up
Creating network "api_default" with the default driver
Pulling ignite (apacheignite/ignite:latest)...
latest: Pulling from apacheignite/ignite
5040bd298390: Pulling fs layer
fce5728aad85: Pulling fs layer
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose\cli\main.py", line 68, in main
File "compose\cli\main.py", line 118, in perform_command
File "compose\cli\main.py", line 926, in up
File "compose\project.py", line 401, in up
File "compose\service.py", line 305, in ensure_image_exists
File "compose\service.py", line 1001, in pull
File "compose\progress_stream.py", line 37, in stream_output
File "codecs.py", line 370, in write
File "site-packages\colorama\ansitowin32.py", line 40, in write
File "site-packages\colorama\ansitowin32.py", line 141, in write
File "site-packages\colorama\ansitowin32.py", line 169, in write_and_convert
File "site-packages\colorama\ansitowin32.py", line 174, in write_plain_text
IOError: [Errno 0] Error
Failed to execute script docker-compose
docker-compose.yml:
version: '3'
services:
ignite:
image: apacheignite/ignite
This error only happens on one of my 3 machines, so I have no idea what causes it. Resetting to factory defaults or reinstalling docker and vscode doesn't help. Without docker compose the image is pulling and then working fine. All the machines are on windows 10 and latest stable docker installed.
Here is the issue I opened on github. It appeared that this behavior only occurs in VSCode powershell console, but not in regular powershell console. The solution with changing encoding suggested there didn't help.
Solution: Update to 1803 on Windows 10. If you can't update, use external command prompt.
The same thing happens to me with Python scripts. Apparently, this is a Windows Update issue:
https://github.com/Microsoft/vscode/issues/36630#issuecomment-359969098
Edit: My workaround due to my company restricting updates is to use external terminal in VS Code

Encountered an error while setting up a Python environment

I'm developing a web-browser extension, and have found a tool which will allow me to publish the extension for all browsers from a single code-base. The tool is called Open Forge and is developed by Trigger.io.
The setup instructions listed in the Open Forge ReadMe (included in the link above) involve creating and configuring a new python environment. I've been able to create and activate a new python environment in my project directory, however the command to configure the environment (pip install -r requirements.txt) generates the following exception:
Exception:
Traceback (most recent call last):
File "C:\Users\ian\Documents\Kitchology\browser-extensions\python-env\lib\site
-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\ian\Documents\Kitchology\browser-extensions\python-env\lib\site
-packages\pip\commands\install.py", line 347, in run
root=options.root_path,
File "C:\Users\ian\Documents\Kitchology\browser-extensions\python-env\lib\site
-packages\pip\req\req_set.py", line 497, in install
and req.installed_version in distribute_req):
File "C:\Users\ian\Documents\Kitchology\browser-extensions\python-env\lib\site
-packages\pip\_vendor\pkg_resources.py", line 2851, in __contains__
return self.specifier.contains(item, prereleases=True)
File "C:\Users\ian\Documents\Kitchology\browser-extensions\python-env\lib\site
-packages\pip\_vendor\packaging\specifiers.py", line 651, in contains
item = parse(item)
File "C:\Users\ian\Documents\Kitchology\browser-extensions\python-env\lib\site
-packages\pip\_vendor\packaging\version.py", line 41, in parse
return Version(version)
File "C:\Users\ian\Documents\Kitchology\browser-extensions\python-env\lib\site
-packages\pip\_vendor\packaging\version.py", line 202, in __init__
match = self._regex.search(version)
TypeError: expected string or buffer
The process hangs on line 17 of the requirements.txt document. The line in question is:
PyHamcrest==1.6
I have also attempted this process on Unix (OS X) and encountered the same error.
I'm able to complete the process successfully by specifying the latest version of PyHamcrest (1.8) in requirements.txt. I've never used PyHamcrest before, and don't feel comfortable speculating as to why 1.8 works while 1.6 does not.

Categories