AttributeError: 'module' object has no attribute 'packages' - python-3.x

when running test i'm getting this error.
earlier i'm using python-requests v2.2.1.so,
i have upgraded python-requests to v2.14.2 but still i'm facing the same issue.
HeaderDict(requests.packages.urllib3._collections.HTTPHeaderDict):
AttributeError: 'module' object has no attribute 'packages'check the below result:
======================================================================
ERROR: rest_blog.tests.test_views (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.4/unittest/case.py", line 58, in testPartExecutor
yield
File "/usr/lib/python3.4/unittest/case.py", line 577, in run
testMethod()
File "/usr/lib/python3.4/unittest/loader.py", line 32, in testFailure
raise exception
ImportError: Failed to import test module: rest_blog.tests.test_views
Traceback (most recent call last):
File "/usr/lib/python3.4/unittest/loader.py", line 312, in _find_tests
module = self._get_module_from_name(name)
File "/usr/lib/python3.4/unittest/loader.py", line 290, in _get_module_from_name
__import__(name)
File "/home/vamsi/PycharmProjects/ReminderToDo/rest_blog/tests/test_views.py", line 6, in <module>
from rest_framework.test import force_authenticate
File "/usr/local/lib/python3.4/dist-packages/rest_framework/test.py", line 30, in <module>
class HeaderDict(requests.packages.urllib3._collections.HTTPHeaderDict):
AttributeError: 'module' object has no attribute 'packages'
----------------------------------------------------------------------

Just reinstalling requests or upgrading requests should solve the problem.
pip install --upgrade requests

Related

Python H2O script: TypeErrors at end/closing

The file h2otest.py contains a shortened version of code on https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/glm.html:
import h2o
h2o.init()
from h2o.estimators.glm import H2OGeneralizedLinearEstimator
prostate = h2o.import_file("https://h2o-public-test-data.s3.amazonaws.com/smalldata/prostate/prostate.csv")
prostate['CAPSULE'] = prostate['CAPSULE'].asfactor()
prostate['RACE'] = prostate['RACE'].asfactor()
prostate['DCAPS'] = prostate['DCAPS'].asfactor()
prostate['DPROS'] = prostate['DPROS'].asfactor()
predictors = ["AGE", "RACE", "VOL", "GLEASON"]
response_col = "CAPSULE"
glm_model = H2OGeneralizedLinearEstimator(family="binomial", lambda_= 0, compute_p_values=True)
glm_model.train(predictors, response_col, training_frame= prostate)
print('Finished')
I run the code on the command line in a Conda environment pycharm, where h2o 3.30.1.3 was installed from PyPi. I am using Python 3.8. I get the same error both on my Mac and a Linux server. There is no existing H2O server at start up :
(pycharm) $> python h2otest.py
The code does it's job, but gives error messages at the end:
...
Parse progress: |█████████████████████████████████████████████████████████████████████████████| 100%
glm Model Build progress: |███████████████████████████████████████████████████████████████████| 100%
Finished
Closing connection _sid_a7a8 at exit
H2O session _sid_a7a8 closed.
Exception ignored in: <function ExprNode.__del__ at 0x7f9ee65f83a0>
Traceback (most recent call last):
File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 204, in __del__
File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 258, in rapids
TypeError: 'NoneType' object is not callable
Exception ignored in: <function ExprNode.__del__ at 0x7f9ee65f83a0>
Traceback (most recent call last):
File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 204, in __del__
File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 258, in rapids
TypeError: 'NoneType' object is not callable
Exception ignored in: <function ExprNode.__del__ at 0x7f9ee65f83a0>
Traceback (most recent call last):
File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 204, in __del__
File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 258, in rapids
TypeError: 'NoneType' object is not callable
Exception ignored in: <function ExprNode.__del__ at 0x7f9ee65f83a0>
Traceback (most recent call last):
File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 204, in __del__
File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 258, in rapids
TypeError: 'NoneType' object is not callable
How can I get rid of those error messages?

Vypython: AttributeError: 'box' object has no attribute 'idx'

I am new to vpython and trying to learn. However, right after installing the module with "pip install vpython" and making a python file that contains this :
from vpython import *
box()
I am greeted with an error:
Traceback (most recent call last):
File "C:/Users/remis/Downloads/Test Vpython.py", line 2, in <module>
box()
File "C:\Users\remis\AppData\Local\Programs\Python\Python38\lib\site-packages\vpython\vpython.py", line 1099, in __init__
super(box, self).setup(args)
File "C:\Users\remis\AppData\Local\Programs\Python\Python38\lib\site-packages\vpython\vpython.py", line 579, in setup
super(standardAttributes, self).__init__()
File "C:\Users\remis\AppData\Local\Programs\Python\Python38\lib\site-packages\vpython\vpython.py", line 236, in __init__
from .no_notebook import _
File "C:\Users\remis\AppData\Local\Programs\Python\Python38\lib\site-packages\vpython\no_notebook.py", line 271, in <module>
__w = threading.Thread(target=__server.serve_forever)
NameError: name '__server' is not defined
Exception ignored in: <function standardAttributes.__del__ at 0x00000182B9D4EAF0>
Traceback (most recent call last):
File "C:\Users\remis\AppData\Local\Programs\Python\Python38\lib\site-packages\vpython\vpython.py", line 1092, in __del__
super(standardAttributes, self).__del__()
File "C:\Users\remis\AppData\Local\Programs\Python\Python38\lib\site-packages\vpython\vpython.py", line 317, in __del__
cmd = {"cmd": "delete", "idx": self.idx}
AttributeError: 'box' object has no attribute 'idx'
I don't see any help online, can I get some please?

anaconda navigator will no longer start even through cmd, won't install or update or manage environments

I'm new to django and using the anaconda cloud environment. Its been working well for 3 months plus but as of 7-24-2018 it is just stop to launch the navigator or open through cmd. I can't manage environments or install packages. Using the anaconda prompt also gives me the same error upon launching. It started when I wanted to install django-Oscar, but not having its dependencies I was forced to install the packages manually which in turn needed cytoolz that needs Microsoft Visual C++ build tools which I got to install as well but the error persists. Please help me!
Copy/Paste of CMD Traceback:
C:\Users\kaukau\Desktop>conda --version conda 4.5.4
C:\Users\kaukau\Desktop>anaconda-navigator Traceback (most recent call
last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\qtpy__init__.py", line
169, in
from PySide import version as PYSIDE_VERSION # analysis:ignore ModuleNotFoundError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\Scripts\anaconda-navigator-script.py", line
6, in
from anaconda_navigator.app.main import main File "C:\Users\kaukau\Anaconda3\lib\site-packages\anaconda_navigator\app\main.py",
line 22, in
from anaconda_navigator.utils.conda import is_conda_available File
"C:\Users\kaukau\Anaconda3\lib\site-packages\anaconda_navigator\utils__init__.py",
line 15, in
from qtpy.QtGui import QIcon File "C:\Users\kaukau\Anaconda3\lib\site-packages\qtpy__init__.py", line
175, in
raise PythonQtError('No Qt bindings could be found') qtpy.PythonQtError: No Qt bindings could be found
C:\Users\kaukau\Desktop>conda install qt --force Traceback (most
recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 819, in call
return func(*args, **kwargs) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
73, in _main
from ..base.context import context File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\Scripts\conda-script.py", line 10, in
sys.exit(main()) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
113, in main
return conda_exception_handler(_main, *args) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 1112, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 822, in call
return self.handle_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 864, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 876, in handle_unexpected_exception
self.print_unexpected_error_report(error_report) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 932, in print_unexpected_error_report
from .base.context import context File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
97, in main
from ..activate import main as activator_main File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\activate.py", line
11, in
from .base.context import ROOT_ENV_NAME, context, locate_prefix_by_name File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\Scripts\conda-script.py", line 10, in
sys.exit(main()) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
110, in main
return ExceptionHandler().handle_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 864, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 876, in handle_unexpected_exception
self.print_unexpected_error_report(error_report) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 932, in print_unexpected_error_report
from .base.context import context File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized
I've just found out that I cant even use any conda commands except the : >conda --version< command only.
Please help me resolve this issue without uninstalling then reinstalling anaconda completely
Sorry to waste your time, I solved it by reinstalling anaconda completely and every project started working again....thanks to those who read it, the effort is appreciated.
It usually happen when you directly download and insall anaconda normally form its website.
Updating anaconda solved this issue for me in Manjaro and will surely work on Windows as well.
use conda update anaconda-navigator command to Update Anaconda.
If it doesn't starts, restart your pc and try to open it again.

keras and tensorflow are not running on gpu in centos 7

I have been trying to run a NN in keras using tf as backend in a centos 7 server but I got this error:
Using Theano backend.
WARNING (theano.configdefaults): install mkl with `conda install mkl-service`: No module named 'mkl'
Traceback (most recent call last):
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/configparser.py", line 1135, in _unify_values
sectiondict = self._sections[section]
KeyError: 'blas'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/configparser.py", line 168, in fetch_val_for_key
return theano_cfg.get(section, option)
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/configparser.py", line 778, in get
d = self._unify_values(section, vars)
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/configparser.py", line 1138, in _unify_values
raise NoSectionError(section)
configparser.NoSectionError: No section: 'blas'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/configparser.py", line 328, in __get__
delete_key=delete_key)
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/configparser.py", line 172, in fetch_val_for_key
raise KeyError(key)
KeyError: 'blas.ldflags'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/configdefaults.py", line 1250, in check_mkl_openmp
import mkl
ImportError: No module named 'mkl'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ffnnecodata2.py", line 1, in <module>
from keras.layers import Input, Dense, LSTM, Activation, Dropout, Reshape
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/keras/backend/__init__.py", line 81, in <module>
from .theano_backend import *
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/keras/backend/theano_backend.py", line 7, in <module>
import theano
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/__init__.py", line 124, in <module>
from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/scan_module/__init__.py", line 41, in <module>
from theano.scan_module import scan_opt
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/scan_module/scan_opt.py", line 60, in <module>
from theano import tensor, scalar
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/tensor/__init__.py", line 17, in <module>
from theano.tensor import blas
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/tensor/blas.py", line 155, in <module>
from theano.tensor.blas_headers import blas_header_text
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/tensor/blas_headers.py", line 987, in <module>
if not config.blas.ldflags:
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/configparser.py", line 332, in __get__
val_str = self.default()
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/configdefaults.py", line 1447, in default_blas_ldflags
check_mkl_openmp()
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/theano/configdefaults.py", line 1262, in check_mkl_openmp
""")
RuntimeError:
Could not import 'mkl'. Either install mkl-service with conda or set
MKL_THREADING_LAYER=GNU in your environment for MKL 2018.
If you have MKL 2017 install and are not in a conda environment you
can set the Theano flag blas.check_openmp to False. Be warned that if
you set this flag and don't set the appropriate environment or make
sure you have the right version you *will* get wrong results.
I'm using a conda environment and I tried to install mkl=2017 but it did not work.
I decided to translate my code to tensorflow and tried to run it again, but I got this message now:
Traceback (most recent call last):
File "tensorffnnecodata.py", line 17, in <module>
import tensorflow as tf
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/tensorflow/__init
.py", line 24, in <module>
from tensorflow.python import * # pylint: disable=redefined-builtin
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/tensorflow/python
_init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/tensorflow/python
ywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/tensorflow/python
ywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/tensorflow/python
ywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/site-packages/tensorflow/python
ywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/imp.py", line 243, in load_modu
return load_dynamic(name, filename, file)
File "/home/powerBuilding/anaconda3/envs/tensorgpu/lib/python3.5/imp.py", line 343, in load_dyna
c
return _load(spec)
ImportError: libcudnn.so.7: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Do you know what is wrong with my installation?
The error suggests that you need to install cuDNN 7.0 (https://developer.nvidia.com/cudnn) for the version of Cuda you have installed from nVidia website and copy over the files to your Cuda installation folder. Prebuilt binaries of Tensorflow 1.7.0+ requires CUDA 9.0
ImportError: libcudnn.so.7: cannot open shared object file: No such file or directory

python3 File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked AttributeError: 'module' object has no attribute '__path__'

My code is runnning in respberry pi 3 and I have error messages while trying to open it in terminal. What's wrong with my code, or where I made mistakes?
And I tried to rename it , but it does not work
import work.py
Traceback (most recent call last):
File "", line 2218, in
_find_and_load_unlocked
AttributeError: 'module' object has no attribute 'path'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "< stdin>", line 1, in < module>
ImportError: No module named 'work.py'; 'work' is not a package

Resources