RuntimeWarning: 'nltk.downloader' found in sys.modules after import of package 'nltk', but prior to execution of 'nltk.downloader' - docker

I'm using docker to run an NLP system that uses nltk, languagetool etc...
When I use docker-compose build --build-arg env=dev I get the warning message:
/usr/local/lib/python3.6/runpy.py:125: RuntimeWarning:
'nltk.downloader' found in sys.modules after import of package 'nltk',
but prior to execution of 'nltk.downloader'; this may result in
unpredictable behaviour warn(RuntimeWarning(msg))
Then when I use docker-compose up I get these errors when trying to run my system:
Please help me figure out how to fix this!

In your Dockerfile:
RUN python -c "import nltk;nltk.download('your_library')"
After pip install nltk

Related

Run npm run start:dev produce ERROR "Cannot find module 'ssh2-streams'"

I am working with docker Nodejs application in Linux Mint 20 OS, and I can run the docker-compose successfully. But when trying to start the application with npm run start:dev it starts watching and then showing the following error:
node_modules/node-ssh/lib/typings/index.d.ts:4:41 - error TS2307: Cannot find module 'ssh2-streams' or its corresponding type declarations.
4 import { Prompt, TransferOptions } from 'ssh2-streams';
[1:30:24 PM] Found 1 error. Watching for file changes.
Plz help!!
run this command for missing type package in your project
npm i #types/ssh2-streams

How do I fix python error occuring when script is run by an app? (macos)

I'm using taskwarrior with a couple of python hooks installed that get triggered when issuing certain taskwarrior commands. The hooks run fine when I use taskwarrior normally from the command line.
But I'm running into problems when the the hooks are trigged by a hotkey app, Karabiner Elements (I'm on a mac). Karabiner calls a perl script which in turn execute this bash command containing the task command:
/bin/bash -c 'TASKRC=/Users/me/.taskrc /usr/local/bin/task add \'the task\''
Unfortunately, the stack error is cutoff in the Karabiner log. This is as much as I get:
[2021-12-07 06:24:51.797] [error] [console_user_server] shell_command stderr:Traceback (most recent call last): File "/Users/me/.task_work/hooks/on-add-pirate", line 9, in <module> from tasklib import TaskWarrior, Task File "/Users/me/Library/Python/3.8/lib/python/site-packages/tasklib/__init__.py", l...
I'm guessing the python script is choking because it can't figure out where needed libraries are. But I don't see any shell environment variables that I might be able to set. I have python3 installed with brew and the tasklib library installed with pip3 (I believe).
Here's the hook script:
#!/usr/bin/env python3
import glob
from types import ModuleType
from importlib.machinery import SourceFileLoader, ModuleSpec
from importlib.util import module_from_spec
import os
from tasklib import TaskWarrior, Task
<-- snip -->
task = Task.from_input()
for hook in find_hooks('pirate_add'):
hook(task)
print(task.export_data())
And here's the __init__.py script mentioned in the error:
from .backends import TaskWarrior
from .task import Task
from .serializing import local_zone
__version__ = '2.2.1'
Ok, problem was bash was defaulting to older version of python3.
The fix is here: https://stackoverflow.com/a/70267561/1641112

Airflow on windows 10 - Module not found errors

I'm new to data science and wanted to do a little tutorial, which requires airflow, among other things. I installed it on windows using git bash in VS Code. I tried running it but it had a problem not being able to load the sqlite3 import
command (module not found error). I figured out that if I added the directory of sqlite3.py to the path, it would run, but now it gives me a similar error: pwd module not found from daemon.py
File "C:\ProgramData\Anaconda3\lib\site-packages\daemon\daemon.py", line 18, in <module>
import pwd
ModuleNotFoundError: No module named 'pwd'
Strange to me that it can't find pwd. Obviously pwd works in both git bash and powershell natively. It seems like a basic universal command. I'd love to learn more about what's going on. I don't want to have to end up adding 100 things to path just to get this program to run. I'd love any insights anyone can provide.
PS I'm using Anaconda.
it's seems to be the side effects of Spawning new Python Daemons .
You likely can fix this by downgrading the Python-Daemon :
pip install python-daemon==2.1.2

bazel building tensorflow serving error

I am running a tensorflow serving container referring to this , all the previous steps are good, but in the last block I met some problems:
git clone --recurse-submodules https://github.com/tensorflow/serving
cd serving/
bazel build -c opt tensorflow_serving/...
root#15bb1c2766e3:/serving# bazel build -c opt tensorflow_serving/...
ERROR:
/root/.cache/bazel/_bazel_root/f8d1071c69ea316497c31e40fe01608c/external/org_tensorflow/third_party/clang_toolchain/cc_configure_clang.bzl:3:1:
file '#bazel_tools//tools/cpp:cc_configure.bzl' does not contain
symbol 'cc_autoconf_impl'. ERROR: error loading package '': Extension
file 'third_party/clang_toolchain/cc_configure_clang.bzl' has errors.
ERROR: error loading package '': Extension file
'third_party/clang_toolchain/cc_configure_clang.bzl' has errors. INFO:
Elapsed time: 0.107s ERROR: Couldn't start the build. Unable to run
tests. And in my container, the bazel version is 0.9.0:
I just came across this error. First please check whether your Bazel version is 0.5.4 by typing the command bazel version.
If the bazel version is 0.5.4 you need to upgrade it to 0.12.0 . For updating you could change Dockerfile.devel BAZEL_VERSION to 0.12.0 and re run all the steps.
Or you could update bazel directly in the docker container by
Download bazel--installer-linux-x86_64.sh from
https://github.com/bazelbuild/bazel/releases location
chmod +x ./bazel--installer-linux-x86_64.sh
./bazel--installer-linux-x86_64.sh
I have already answered this on github and it worked. Please refer to the links https://github.com/tensorflow/serving/issues/851 and https://github.com/tensorflow/serving/issues/854

Dataflow wordcount.py example " Import by filename is not supported"

Using Ubuntu 14.04,
DataFlow Python SDK
Following instructions at [https://github.com/GoogleCloudPlatform/DataflowPythonSDK#status-of-this- release] , after everything is loaded when I try the wordcount example I try get the error "Import by filename is not supported".
I suspect the issue is at line 23 of the wordcount.py example
import google.cloud.dataflow as df
Is there a workaround for this issue?
I have tried the solution posted at Python / ImportError: Import by filename is not supported , but that does not solve the problem.
Since this fails at the first import statement the immediate thing to check is if the Python Dataflow package is installed at all. Th way to do that is by running 'pip freeze'. Here is some output from running this in a virtual environment:
$ pip freeze
... Nothing since it is a clean virtual environment ...
$ pip install https://github.com/GoogleCloudPlatform/DataflowPythonSDK/archive/v0.2.3.tar.gz
... Output from installing packages ...
$ pip freeze
...
python-dataflow==0.2.3
...
Now you can run python and execute 'import google.cloud.dataflow as df' and it should work.
Hopefully this helps!

Resources