How to import TensorMetric in pytorch lighting? - pytorch-lightning

I want to import TensorMetric :
from pytorch_lightning.metrics.metric import TensorMetric
The program throws an exception:
ModuleNotFoundError: No module named 'pytorch_lightning.metrics'
My environment is:
Python 3.8.13
tokenizers==0.9.2
torch==1.5.1
transformers==3.4.0
pytorch-lightning==0.9.0
tensorboard==2.2.0

0.9 is a very old version of Lightning and a lot has changed/improved since then. I would recommend you to use the latest version of PyTorch Lightning (1.6).
Also, we have metrics as a separate library now TorchMetrics.

Related

Opentelemetry python

HP ENVY 17" i7 laptop:
Kubuntu 21.10
Greetings, I'm relatively new to Opentelemetry. I've followed many tutorials including opentelemetry.io but I keep running into dependency problems with the python stack.
What is the expected behavior?
I don't expect any error
What is the actual behavior?
python ./metrics01.py ─╯
Traceback (most recent call last):
File "/home/iomari/temp/opentelemetry/newsample/./metrics01.py", line 7, in <module>
from opentelemetry.sdk.metrics.export.controller import PushController
ModuleNotFoundError: No module named 'opentelemetry.sdk.metrics.export.controller'
Additional context:
Using opentelemetry-python 1.12.0rc1:
─ pip freeze ─╯
asttokens==2.0.5
backcall==0.2.0
backoff==1.11.1
certifi==2022.6.15
chainmap==1.0.3
charset-normalizer==2.0.12
colorama==0.4.5
combomethod==1.0.12
decorator==5.1.1
Deprecated==1.2.13
executing==0.8.3
googleapis-common-protos==1.56.3b1
grpcio==1.47.0rc1
idna==3.3
ipython==8.4.0
jedi==0.18.1
matplotlib-inline==0.1.3
nulltype==2.3.1
opentelemetry-api==1.12.0rc1
opentelemetry-distro==0.31b0
opentelemetry-exporter-jaeger==1.12.0rc1
opentelemetry-exporter-jaeger-proto-grpc==1.12.0rc1
opentelemetry-exporter-jaeger-thrift==1.12.0rc1
opentelemetry-exporter-otlp==1.12.0rc1
opentelemetry-exporter-otlp-proto-grpc==1.12.0rc1
opentelemetry-exporter-otlp-proto-http==1.12.0rc1
opentelemetry-exporter-prometheus==1.12.0rc1
opentelemetry-instrumentation==0.31b0
opentelemetry-propagator-b3==1.12.0rc1
opentelemetry-propagator-jaeger==1.12.0rc1
opentelemetry-proto==1.12.0rc1
opentelemetry-sdk==1.12.0rc1
opentelemetry-semantic-conventions==0.31b0
options==1.4.10
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
prometheus-client==0.14.1
prompt-toolkit==3.0.29
protobuf==3.20.0
ptyprocess==0.7.0
pure-eval==0.2.2
Pygments==2.12.0
requests==2.28.0
six==1.12.0
stack-data==0.3.0
termcolor==1.1.0
thrift==0.16.0
traitlets==5.3.0
typing_extensions==4.2.0
urllib3==1.26.9
wcwidth==0.2.5
wrapt==1.14.1
Problem solved.
Did a pip cache purge, reinstalled all modules and all is working.

Rasa init cannot be executed

my rasa init --no-prompt is throwing some import error
ImportError: This version of TensorFlow Probability requires TensorFlow version >= 1.14; Detected an installation of version 1.13.2. Please upgrade TensorFlow to proceed.
Although when i tried to change the tensorflow version it throws the same error.
ImportError: This version of TensorFlow Probability requires TensorFlow version >= 1.14; Detected an installation of version 1.13.2. Please upgrade TensorFlow to proceed.
This is my pip freeze
absl-py==0.8.0
aiofiles==0.4.0
aiohttp==3.5.4
alembic==1.0.11
APScheduler==3.6.0
asn1crypto==0.24.0
astor==0.8.0
async-generator==1.10
async-timeout==3.0.1
attrs==19.1.0
blis==0.2.4
boto3==1.9.146
botocore==1.12.221
bz2file==0.98
cachetools==3.1.1
certifi==2019.6.16
cffi==1.12.3
chardet==3.0.4
Click==7.0
cloudpickle==1.2.1
colorama==0.4.1
colorclass==2.2.0
coloredlogs==10.0
colorhash==1.0.2
ConfigArgParse==0.14.0
cryptography==2.7
cycler==0.10.0
cymem==2.0.2
Cython==0.29.13
decorator==4.4.0
dill==0.3.0
docopt==0.6.2
docutils==0.15.2
dopamine-rl==2.0.5
en-core-web-md==2.1.0
fakeredis==1.0.3
fbmessenger==6.0.0
Flask==1.1.1
Flask-Cors==3.0.8
future==0.17.1
gast==0.2.2
gevent==1.4.0
gin-config==0.2.1
google-api-python-client==1.7.11
google-auth==1.6.3
google-auth-httplib2==0.0.3
google-pasta==0.1.7
googleapis-common-protos==1.6.0
greenlet==0.4.15
grpcio==1.23.0
gunicorn==19.9.0
gym==0.14.0
h5py==2.9.0
httplib2==0.13.1
httptools==0.0.13
humanfriendly==4.18
idna==2.8
isodate==0.6.0
itsdangerous==1.1.0
Jinja2==2.10.1
jmespath==0.9.4
jsonpickle==1.1
jsonschema==2.6.0
kafka-python==1.4.6
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
kfac==0.2.0
kiwisolver==1.1.0
Mako==1.1.0
Markdown==3.1.1
MarkupSafe==1.1.1
matplotlib==3.0.3
mattermostwrapper==2.1
mesh-tensorflow==0.0.5
mock==3.0.5
mpmath==1.1.0
multidict==4.5.2
murmurhash==1.0.2
networkx==2.3
numpy==1.16.3
oauth2client==4.1.3
object-detection==0.1
opencv-python==4.1.1.26
packaging==19.0
pika==1.0.1
Pillow==6.1.0
plac==0.9.6
preshed==2.0.1
promise==2.2.1
prompt-toolkit==2.0.9
protobuf==3.9.1
psutil==5.6.3
psycopg2-binary==2.8.2
pyasn1==0.4.7
pyasn1-modules==0.2.6
pycparser==2.19
pydot==1.4.1
pyglet==1.3.2
PyJWT==1.7.1
pykwalify==1.7.0
pymongo==3.8.0
pyparsing==2.4.2
pypng==0.0.20
pyreadline==2.1
PySocks==1.7.0
python-crfsuite==0.9.6
python-dateutil==2.8.0
python-editor==1.0.4
python-engineio==3.9.3
python-socketio==4.0.1
python-telegram-bot==11.1.0
pytz==2019.1
PyYAML==5.1.2
questionary==1.1.1
-e git+https://github.com/RasaHQ/rasa.git#4d1db2a755355031eb776e05bdf102159b1ccf8c#egg=rasa
rasa-sdk==1.3.0a1
rasa-x==0.20.2
redis==3.3.5
requests==2.22.0
requests-toolbelt==0.9.1
rocketchat-API==0.6.31
rsa==4.0
ruamel.yaml==0.15.94
s3transfer==0.2.1
sanic==19.3.1
Sanic-Cors==0.9.8
sanic-jwt==1.3.1
Sanic-Plugins-Framework==0.8.2
scikit-learn==0.20.2
scipy==1.2.1
setuptools-scm==3.3.3
simplejson==3.16.0
six==1.12.0
sklearn-crfsuite==0.3.6
slackclient==1.3.1
sortedcontainers==2.1.0
spacy==2.1.4
SQLAlchemy==1.3.8
srsly==0.1.0
sympy==1.4
tabulate==0.8.3
tensor2tensor==1.14.0
tensorboard==1.14.0
tensorflow==1.14.0
tensorflow-datasets==1.2.0
tensorflow-estimator==1.14.0
tensorflow-gan==1.0.0.dev0
tensorflow-metadata==0.14.0
tensorflow-probability==0.7.0
termcolor==1.1.0
terminaltables==3.1.0
thinc==7.0.8
tqdm==4.31.0
twilio==6.26.3
tzlocal==2.0.0
uritemplate==3.0.0
urllib3==1.25.3
wasabi==0.2.2
wcwidth==0.1.7
webexteamssdk==1.1.1
websocket-client==0.54.0
websockets==6.0
Werkzeug==0.15.5
wrapt==1.11.2
yarl==1.3.0
In my environment the version of tensorflow is 1.14 but i dont know why is it throwing the same error.there was some initial error with Rasa sdk version,can someone guide me through right direction please.
I think your versions of libraries are outdated and not compatible with tenserflow. Unless you want exact versions of those libraries you can just install the latest version of it without specify the version of it. If you want those version only try uninstall tenserflow and re-install with a version specified.

Rasa installed but rasa_nlu.converters not found

Rasa version: 0.14.6
Python version: 3.6.4
Operating system: osx
Issue:
Running a snippet with this line :
from rasa_nlu.converters import load_data
Getting this error :
Traceback (most recent call last): File "nlu_model.py", line 1, in
from rasa_nlu.converters import load_data ModuleNotFoundError: No
module named 'rasa_nlu.converters'
However, pip freeze | grep rasa-nlu returns
rasa-nlu==0.14.6
Content of configuration file (config.yml):
language: "en"
pipeline: spacy_sklearn
I guess you are following wrong documentation as you are using v0.14.6 the appropriate way to import load_data is :
from rasa_nlu.training_data import load_data
In rasa-nlu version 0.14.6 and newer versions the correct path is
rasa_nlu.convert.
Depending on what you are trying to do with the command this now would be something like:
from rasa_nlu.convert import convert_training_data,
from rasa_nlu.convert import add_arguments or
from rasa_nlu.convert import main
where main() is:
def main(args):
convert_training_data(args.data_file,
args.out_file,
args.format,
args.language)

cx_Freeze encodings for creating macOS application

I am trying to create a standalone Python3 macOS application including tkinter and selenium by using cx_Freeze. There are three files in my project:
tkinter_tab3.py (contains GUI)
user.txt (contains user info)
ver004.py (called from tkinter_tab3.py and executes tasks)
I created the following setup.py file with tkinter_tab3.py being the file to be turned into the executable:
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = ['encodings'], excludes = [])
includefiles = ['user.txt', 'ver004.py']
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('tkinter_tab3.py', base=base, targetName = 'suprbotcho')
]
setup(name='suprbotcho',
version = '1.0',
description = 'test',
options = dict(build_exe = buildOptions),
executables = executables)
However, when I run $python3 setup.py build then click on the created executable, I receive this error back in the terminal:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
In addition, when I run $python3 setup.py bdist.mac and $python3 setup.py bdist.dmg, I receive the following error:
build/suprbotcho-1.0.app/Contents/MacOS/lib/numpy/core/lib/libnpymath.a(npy_math.o):
error: can't copy 'build/suprbotcho-1.0.app/Contents/MacOS/lib/numpy/core/lib/libnpymath.a(npy_math.o):': doesn't exist or not a regular file
I do not understand where I am going wrong because I have read other posts about the encodings problem however I found no progress after trying out the posted solutions.
Here are the imports for each python file:
tkinter_tab3.py
from tkinter import *
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import numpy as np
import time
from datetime import datetime
from threading import Timer
from ver004 import SuPrBoTcHo, InIt_UsEr
ver004.py
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import numpy as np
import time
from datetime import datetime
from threading import Timer
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import NoSuchElementException
If I could get help on fixing this particular problem, that would be great. If you have any particular questions, feel free to let me know.
(python version: 3.6.3)
I had the same problem.
The solution was to upgrade cxfreeze to the latest version, i.e do the following steps-
pip install -U cx_Freeze==6.0.b1

Haskell - System.Process callCommand and other functions are not available

While reading the docs of System.Process and trying to use callCommand I discovered that it is not available:
test.hs:1:24: Module `System.Process' does not export `callCommand'
Why?
callProcess was added to the process library in version 1.2.0.0. I suspect you are using an earlier version.

Resources