Installed Miniconda 4.2.11 and have import error while creating environment - anaconda

I am able to create environment from environment.yml file which has release number 4.2.7 but recently updated miniconda distribution on my Desktop to 4.2.11. Can I go back to my previous distribution?
Snippet of the error:
Traceback (most recent call last):
File "/Users/ramya/miniconda2/bin/conda-env", line 4, in <module>
import conda_env.cli.main
File "/Users/ramya/miniconda2/lib/python2.7/site-packages/conda_env/cli/main.py", line 35, in <module>
from . import main_attach
File "/Users/ramya/miniconda2/lib/python2.7/site-packages/conda_env/cli/main_attach.py", line 4, in <module>
from ..env import from_environment
File "/Users/ramya/miniconda2/lib/python2.7/site-packages/conda_env/env.py", line 17, in <module>
from . import yaml
File "/Users/ramya/miniconda2/lib/python2.7/site-packages/conda_env/yaml.py", line 8, in <module>
import yaml

Answering my own question here - I got hold of a previous download of Miniconda (Miniconda2-latest-MacOSX-x86_64.sh) Installation file and created my environment which resolved my problem.

Related

No module named 'tokenize'

Trouble with anaconda:
Error message below.
Reason why I think this is happening:
Accidentally deleted some files
I tried to uninstall Anaconda, and reinstall, however, when reinstalling - installer says Anaconda already installed, hence, not able to get Anaconda working.
Scanned through the net and stackoverflow, but unable to find an answer. Error message below:
"
Traceback (most recent call last):
File "/miniconda3/bin/conda", line 13, in <module>
sys.exit(main())
File "/miniconda3/lib/python3.7/site-packages/conda/cli/main.py", line 149, in main
from ..exceptions import conda_exception_handler
File "/miniconda3/lib/python3.7/site-packages/conda/exceptions.py", line 10, in <module>
from logging import getLogger
File "/miniconda3/lib/python3.7/logging/__init__.py", line 26, in <module>
import sys, os, time, io, traceback, warnings, weakref, collections.abc
File "/miniconda3/lib/python3.7/traceback.py", line 5, in <module>
import linecache
File "/miniconda3/lib/python3.7/linecache.py", line 11, in <module>
import tokenize
ModuleNotFoundError: No module named 'tokenize' "

Keras installed but not working

I am using keras with theano as the back end to build a neural network on windows 10. My python version is 2.7. The problem is that when I try and use keras I keep getting a path error.
$python
>>import keras
Gives me the error
Problem occurred during compilation with the command line below:
"g++" -shared -g -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -I"C:\Python27\lib\site-packages\numpy\core\include" -I"C:\Python27\include" -I"C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\gof" -L"C:\Python27\libs" -L"C:\Python27" -o C:\Users\Patrick\AppData\Local\Theano\compiledir_Windows-10-10.0.14393-Intel64_Family_6_Model_61_Stepping_4_GenuineIntel-2.7.11-64\lazylinker_ext\lazylinker_ext.pyd C:\Users\Patrick\AppData\Local\Theano\compiledir_Windows-10-10.0.14393-Intel64_Family_6_Model_61_Stepping_4_GenuineIntel-2.7.11-64\lazylinker_ext\mod.cpp -lpython27
The system cannot find the path specified.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\keras-2.0.3-py2.7.egg\keras\__init__.py", line 3, in <module>
from . import activations
File "C:\Python27\lib\site-packages\keras-2.0.3-py2.7.egg\keras\activations.py", line 4, in <module>
from . import backend as K
File "C:\Python27\lib\site-packages\keras-2.0.3-py2.7.egg\keras\backend\__init__.py", line 70, in <module>
from .theano_backend import *
File "C:\Python27\lib\site-packages\keras-2.0.3-py2.7.egg\keras\backend\theano_backend.py", line 3, in <module>
import theano
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\__init__.py", line 66, in <module>
from theano.compile import (
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\compile\__init__.py", line 10, in <module>
from theano.compile.function_module import *
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\compile\function_module.py", line 21, in <module>
import theano.compile.mode
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\compile\mode.py", line 10, in <module>
import theano.gof.vm
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\gof\vm.py", line 662, in <module>
from . import lazylinker_c
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\gof\lazylinker_c.py", line 127, in <module>
preargs=args)
File "C:\Python27\lib\site-packages\theano-0.9.0-py2.7.egg\theano\gof\cmodule.py", line 2316, in compile_str
(status, compile_stderr.replace('\n', '. ')))
. ception: Compilation failed (return status=1): The system cannot find the path specified.
>>>
I can tell that I need to add to my system variables paths (at least I think so...) but no matter what I add I still get the error. I have tried adding
C:\Python27\lib
C:\Python27\lib\site-packages
Basically any of the paths it said could not be specified. Something to note would be that I had a lot of trouble getting scipy installed and had to get the .whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy not sure if that helps at all. Well that's my issue.
I was also facing the same issue and resolved with removing other python versions. Make sure that you have only 1 python installed. If there is multiple, thing sometimes don't work very well.
What i would suggest is use keras in a separate environment using conda.
Suppose you want to create an env named "myenv"
1.Open Anaconda promt and type the following:
conda create --name myenv
2.To activate the environment:
conda activate myenv
3.Now you can install keras and other dependencies:
pip install keras
Install tensorflow as follows.
pip install tensorflow==2.0.0

Ambari HDP 2.4 Add Hosts Metrics Monitor fail to Install

I'm trying to add some more hosts to my Ambari Cluster, running HDP 2.4 and the Metrics Monitor does not seem to be installing correctly, all the other services are starting fine.
Below is the output I get when I attempt to start Metrics Monitor on one of the new hosts.
255. Building psutil...
Traceback (most recent call last):
File "setup.py", line 15, in <module>
from setuptools import setup, Extension
File "/usr/lib/python2.7/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/usr/lib/python2.7/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/usr/lib/python2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
Verifying Python version compatibility...
Using python /usr/bin/python2.7
Checking for previously running Metric Monitor...
Starting ambari-metrics-monitor
Verifying ambari-metrics-monitor process status...
ERROR: ambari-metrics-monitor start failed. For more details, see /var/log/ambari-metrics-monitor/ambari-metrics-monitor.out:
====================
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/resource_monitoring/main.py", line 27, in <module>
from core.controller import Controller
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/controller.py", line 28, in <module>
from metric_collector import MetricsCollector
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/metric_collector.py", line 23, in <module>
from host_info import HostInfo
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/host_info.py", line 22, in <module>
import psutil
ImportError: No module named psutil
====================
Monitor out at: /var/log/ambari-metrics-monitor/ambari-metrics-monitor.out
And this is the output of /var/log/ambari-metrics-monitor/ambari-metrics-monitor.out
psutil binaries need to be built by running, psutil/build.py manually or by running a, mvn clean package, command.
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/resource_monitoring/main.py", line 27, in <module>
from core.controller import Controller
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/controller.py", line 28, in <module>
from metric_collector import MetricsCollector
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/metric_collector.py", line 23, in <module>
from host_info import HostInfo
File "/usr/lib/python2.6/site-packages/resource_monitoring/core/host_info.py", line 22, in <module>
import psutil
ImportError: No module named psutil
I have tried going into that directory and running sudo python psutil/build.py, as well as running sudo make. Both do not work.
Any ideas would be great!
This is an issue with your python environment, it's been corrupted somehow (most likely using sudo pip install <package>, using sudo and pip together can sometimes cause this issue). There are details on how to fix this issue on this SO question. After you fix your python issue you should be able to retry the host addition through Ambari.

Letsencrypt certificate upgrade issue

On Ubuntu 16.04.2 LTS, I am trying to upgrade letsencrypt certificate by using
./letsencrypt-auto renew --dry-run and its giving below error
Error: couldn't get currently installed version for /root/.local/share/letsencrypt/bin/letsencrypt:
Traceback (most recent call last):
File "/root/.local/share/letsencrypt/bin/letsencrypt", line 7, in <module>
from certbot.main import main
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot/main.py", line 13, in <module>
from acme import jose
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/acme/jose/__init__.py", line 37, in <module>
from acme.jose.interfaces import JSONDeSerializable
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/acme/jose/interfaces.py", line 9, in <module>
from acme.jose import util
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/acme/jose/util.py", line 4, in <module>
from cryptography.hazmat.primitives.asymmetric import rsa
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 14, in <module>
from cryptography.hazmat.backends.interfaces import RSABackend
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
import pkg_resources
File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 36, in <module>
import plistlib
File "/usr/lib/python2.7/plistlib.py", line 62, in <module>
import datetime
ImportError: No module named datetime
Can you please help here
Just do
rm -rf /root/.local/share/letsencrypt/bin/letsencrypt
and try again.
I solved this problem by deleting the virtualenv bin directory and re-running the certbot-auto command, which will cause certbot to re-install dependencies. To find the location of the directory, look at the first line of the error response:
Error: couldn't get currently installed version for /root/.local/share/letsencrypt/bin/letsencrypt. This location will vary.
Accordingly, deleting /root/.local/share/letsencrypt/bin/ should remove the installed dependencies and got the certs but up and running.
This works for me (Linux Debian 3.16.64-2):
mv /opt/eff.org/certbot /opt/eff.org/certbot.old
certbot-auto

anaconda macOS ImportError: cannot import name 'MappingProxyType'

I just installed anaconda with python 3 on my mac (macOS Sierra 10.12.2), and many packages give off errors when importing. It seems this has to do with the typing package, but I can't figure out what's going on.
If I do
python -c 'import sklearn'
(python being Python 3.5.2 :: Anaconda 4.2.0 (x86_64))
I get this error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/geromepistre/anaconda3/lib/python3.5/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/Users/geromepistre/anaconda3/lib/python3.5/site-packages/sklearn/base.py", line 6, in <module>
import copy
File "/Users/geromepistre/anaconda3/lib/python3.5/copy.py", line 51, in <module>
import types
File "/Users/geromepistre/types.py", line 1, in <module>
import typing
File "/Users/geromepistre/anaconda3/lib/python3.5/typing.py", line 4, in <module>
import contextlib
File "/Users/geromepistre/anaconda3/lib/python3.5/contextlib.py", line 5, in <module>
from functools import wraps
File "/Users/geromepistre/anaconda3/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
I tried to dig into the packages mentioned in the error, but it gets more confusing.
import types gives the same error, as well as import contextlib. But if I import contextlib first (and get an error), then import types gets me no error. And I get a brand new error on import sklearn:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/geromepistre/anaconda3/lib/python3.5/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/Users/geromepistre/anaconda3/lib/python3.5/site-packages/sklearn/base.py", line 6, in <module>
import copy
File "/Users/geromepistre/anaconda3/lib/python3.5/copy.py", line 114, in <module>
types.BuiltinFunctionType, type(Ellipsis),
AttributeError: module 'types' has no attribute 'BuiltinFunctionType'
You appear to be running Python from your home directory, which according to the first traceback contains a file named types.py. Since the current directory (. in Unix/Linux parlance) is the first entry in sys.path, Anaconda searches for modules/files there before the standard lib or site-packages.
Try at all costs to avoid naming files for modules in either the standard lib or site-packages, for just this reason. Renaming your file types.py to my_types.py or something should solve the issue.

Resources