no attribute 'contrib' for problems() - python

I am trying to see the available problems() but it is giving Error.
Can you please let me know if I am missing anything
>>> from tensor2tensor import problems
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\\Anaconda3\lib\site-packages\tensor2tensor\problems.py", line 22, in <module>
from tensor2tensor.utils import registry
File "C:\Users\\Anaconda3\lib\site-packages\tensor2tensor\utils\registry.py", line 551, in <module>
attacks = tf.contrib.framework.deprecated(None, "Use registry.attack")(attack)
AttributeError: module 'tensorflow' has no attribute 'contrib'
>>> tf.__version__
'2.0.0-beta1'
>>>
I am working on windows

Tensor2Tensor library is not yet compatible with Tensorflow 2.0 because it still uses a lot of deprecated APIs. Your only option currently is to downgrade to an older version, such as Tensorflow 1.15.
pip3 install tensorflow==1.15.0

Related

AttributeError: module 'tensorflow.keras.optimizers' has no attribute 'legacy'

I'm attempting to configure the TensorFlow object detection API TFOD in a Python virtual environment with python=3.10.9, TensorFlow=2.8.0, CUDA=11.2 and CuDNN=8.1. I've already passed the verification script and everything works fine until I want to train the model and paste the command below into the command prompt:
python Tensorflow\models\research\object_detection\model_main_tf2.py --model_dir=Tensorflow\workspace\models\my_ssd_mobnet --pipeline_config_path=Tensorflow\workspace\models\my_ssd_mobnet\pipeline.config --num_train_steps=2000
The error it shows me is:
C:\Users\vetran2\pyproj\tfodnew\lib\site-packages\tensorflow_addons\utils\ensure_tf_install.py:53: UserWarning: Tensorflow Addons supports using Python ops for all Tensorflow versions above or equal to 2.9.0 and strictly below 2.12.0 (nightly versions are not supported).
The versions of TensorFlow you are currently using is 2.8.0 and is not supported.
Some things might work, some things might not.
If you were to encounter a bug, do not file an issue.
If you want to make sure you're using a tested and supported configuration, either change the TensorFlow version or the TensorFlow Addons's version.
You can find the compatibility matrix in TensorFlow Addon's readme:
https://github.com/tensorflow/addons
warnings.warn(
Traceback (most recent call last):
File "D:\ObjectDetection\TensorFlow Object Detection\TFODCourse\Tensorflow\models\research\object_detection\model_main_tf2.py", line 31, in <module>
from object_detection import model_lib_v2
File "C:\Users\vetran2\pyproj\tfodnew\lib\site-packages\object_detection-0.1-py3.10.egg\object_detection\model_lib_v2.py", line 31, in <module>
from object_detection import model_lib
File "C:\Users\vetran2\pyproj\tfodnew\lib\site-packages\object_detection-0.1-py3.10.egg\object_detection\model_lib.py", line 35, in <module>
from object_detection.builders import optimizer_builder
File "C:\Users\vetran2\pyproj\tfodnew\lib\site-packages\object_detection-0.1-py3.10.egg\object_detection\builders\optimizer_builder.py", line 25, in <module>
from official.modeling.optimization import ema_optimizer
File "C:\Users\vetran2\pyproj\tfodnew\lib\site-packages\tf_models_official-2.11.3-py3.10.egg\official\modeling\optimization\__init__.py", line 21, in <module>
from official.modeling.optimization.ema_optimizer import ExponentialMovingAverage
File "C:\Users\vetran2\pyproj\tfodnew\lib\site-packages\tf_models_official-2.11.3-py3.10.egg\official\modeling\optimization\ema_optimizer.py", line 24, in <module>
class ExponentialMovingAverage(tf.keras.optimizers.legacy.Optimizer):
AttributeError: module 'tensorflow.keras.optimizers' has no attribute 'legacy'

Can't import "ImportObject" from python "wasmer"

So easy to reproduce that I'm surprised that nobody has reported it yet.
pip install wasmer
python -c 'from wasmer import ImportObject'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'ImportObject' from 'wasmer' (/usr/lib/python3.8/site-packages/wasmer.cpython-38-x86_64-linux-gnu.so
"ImportObject" class is described in readme and presented in examples. I've checked that proper 0.4.1 version of "wasmer" was installed. Also I checked the newest tagged version of "wasmer" which fails with the same error. Do I do something totally wrong?
UPD: generate_import_object() function doesn't work also:
python -c "from wasmer import Module; Module.generate_import_object()"
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: type object 'Module' has no attribute 'generate_import_object'
And this code gives the same result:
wasm_bytes = open('binary.wasm', 'rb').read()
module = Module(wasm_bytes)
import_object = module.generate_import_object()
The library in pip is outdated. The current version is from March, 2nd, and the necessary changes were implemented only on June, 2nd. 0.4.2 beta version is outdated also (May, 19). So, the only way now is manual build. Probably the library will be updated in a couple of weeks.
See more details in this thread: https://github.com/wasmerio/python-ext-wasm/issues/215.

undefined symbol: PyOS_mystrnicmp

I tried installing pysqlite, but I'm having some trouble using it.
>>> import pysqlite2.dbapi2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/.pyenv/versions/2.7.5/lib/python2.7/site-packages/pysqlite2/dbapi2.py", line 28, in <module>
from pysqlite2._sqlite import *
ImportError: /data/.pyenv/versions/2.7.5/lib/python2.7/site-packages/pysqlite2/_sqlite.so: undefined symbol: PyOS_mystrnicmp
I think I might be missing some Python headers. Where do I find them? I'm using CentOS with CPython 2.7.5.
As https://groups.google.com/forum/#!topic/python-sqlite/04Ocf7aP1so points out, a bug was reported that appears to be fixed in newer versions of Python. Upgrading to a later version of Python 2.7 did the trick for me.

AttributeError: 'module' object has no attribute 'moves'

I'm trying to install Ansible, but I can never get a clean install for some reason. using apt-get install ansible and then doing a ansible --version I get the following output:
Traceback (most recent call last):
File "/usr/bin/ansible", line 44, in <module>
import ansible.constants as C
File "/usr/lib/python2.7/dist-packages/ansible/constants.py", line 26, in <module>
from ansible.compat.six import string_types
File "/usr/lib/python2.7/dist-packages/ansible/compat/six/__init__.py", line 40, in <module>
not hasattr(_system_six.moves, 'shlex_quote') or
AttributeError: 'module' object has no attribute 'moves'
Ansible is still very young and OS packaging is lagging behind. Although this particular error may simply be caused by a version mismatch or missing dependency.
May I suggest running Ansible from source?

Python tensorflow error, sys has no attribute getdlflags

I Just attempted to install tensorflow for python and when I went to the console to see if the init.py was working it returned this error. I installed it manualy without pip or any other package manager.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\*username\AppData\Local\Programs\Python\Python35-32\lib\tensorflow\__init__.py", line 43, in <module>
_default_dlopen_flags = sys.getdlopenflags()
AttributeError: module 'sys' has no attribute 'getdlopenflags'
TensorFlow is not supported on Windows yet. Please follow this github issue which tracks TensorFlow Windows support.

Categories

Resources