anaconda macOS ImportError: cannot import name 'MappingProxyType' - macos

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.

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' "

pip is giving import error while doing any operation

I have already worked other methods but nothing works and i get this error.
i am on windows 10 currently
C:\WINDOWS\system32>pip install --upgrade pip==9.0.3
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\pip-script.py", line 6, in <module>
from pip._internal import main
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\__init__.py", line 42, in <module>
from pip._internal import cmdoptions
ImportError: cannot import name 'cmdoptions'

Theano error after pip install

I have been trying to get Theano as backend for Keras on my 32-bit Windows 10. I have installed a bunch of different things, such as CUDA and Python 3.5 (I have 3.6.5 as my default) and even installed with Anaconda. The Anaconda download wasn't there when I used pip freeze in my terminal, and my code didn't recognize it after the conda install, so I simply pip installed Theano, which always gives me this error when I run it. I normally use Atom, not Anaconda, so I'm not sure if a conda install doesn't work for Atom. I am also unsure of how to switch my code in Atom to Python 3.5, as I know Theano only works up to 3.5, or if it's even necessary. I had previously installed my g++ gcc compiler through MinGW, which I have a suspicion might be the culprit for this error as well, as similar errors on StackOverflow questions had to do with this. The error is listed below. This has been a nightmare installation process, so I apologize for all the info about everything I've been doing. Help would be much appreciated.
Also, when I import Keras in my terminal with python 3.5, it says there is no such module.
Something is horribly wrong.
The error:
Using Theano backend.
You can find the C code in this temporary file: C:\Users\AARONM~1\AppData\Local\Temp\theano_compilation_error_9whx6ow7
Traceback (most recent call last):
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\lazylinker_c.py", line 75, in <module>
raise ImportError()
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\lazylinker_c.py", line 92, in <module>
raise ImportError()
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Aaron Mazie\Desktop\tradingbots\testntrain6.py", line 11, in <module>
from keras.layers.core import Dense, Activation, Dropout
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\keras\backend\__init__.py", line 81, in <module>
from .theano_backend import *
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\keras\backend\theano_backend.py", line 7, in <module>
import theano
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\__init__.py", line 110, in <module>
from theano.compile import (
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\compile\__init__.py", line 12, in <module>
from theano.compile.mode import *
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\compile\mode.py", line 11, in <module>
import theano.gof.vm
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\vm.py", line 673, in <module>
from . import lazylinker_c
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\lazylinker_c.py", line 127, in <module>
preargs=args)
File "C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\cmodule.py", line 2359, in compile_str
(status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\math.h:36:0,
. from C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\include/pyport.h:194,
. from C:\Users\Aaron Mazie\AppData\Local\Programs\Python\Python36-32\include/Python.h:53,
. from C:\Users\Aaron Mazie\AppData\Local\Theano\compiledir_Windows-10-10.0.16299-SP0-Intel64_Family_6_Model_142_Stepping_9_GenuineIntel-3.6.5-32\lazylinker_ext\mod.cpp:1:
. c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\cmath:1157:11: error: '::hypot' has not been declared
. using ::hypot;
. ^~~~~
.
For anyone wondering, I uninstalled everything, including the Theano cache files manually, and watched this vid: https://www.youtube.com/watch?v=J70j6q7aOi4&t=131s&index=1&list=LLwpbw2KREgJdXEC0gLRTy4g

Installed Miniconda 4.2.11 and have import error while creating environment

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.

install pyshark on python 3.5

I've installed python 3.5 on mac os x (el capitan). I want to import pyshark module in python, but I get error.
I installed the pyshark requirement such as (logbook, lxml, trollies, py) but I couldn't import pyshark module.
pip3 list >>
syncio (3.4.3)
futures (3.0.3)
Logbook (0.12.3)
lxml (3.5.0)
pip (7.1.2)
py (1.4.30)
pyshark (0.3.6)
setuptools (18.2)
trollius (2.0)
Importing pyshark module error:
>>> import pyshark
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyshark/__init__.py", line 1, in <module>
from pyshark.capture.live_capture import LiveCapture
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyshark/capture/live_capture.py", line 1, in <module>
from pyshark.capture.capture import Capture
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyshark/capture/capture.py", line 6, in <module>
import trollius as asyncio
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/__init__.py", line 21, in <module>
from .base_events import *
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/base_events.py", line 39, in <module>
from . import coroutines
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/coroutines.py", line 15, in <module>
from . import futures
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/futures.py", line 116, in <module>
class Future(object):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/futures.py", line 426, in Future
__await__ = __iter__ # make compatible with 'await' expression
NameError: name '__iter__' is not defined
Also importing trollies module has a error:
>>> import trollius
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/__init__.py", line 21, in <module>
from .base_events import *
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/base_events.py", line 39, in <module>
from . import coroutines
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/coroutines.py", line 15, in <module>
from . import futures
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/futures.py", line 116, in <module>
class Future(object):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/trollius/futures.py", line 426, in Future
__await__ = __iter__ # make compatible with 'await' expression
NameError: name '__iter__' is not defined
Could any one help me out? I can't figure out what is the problem.
This is reported as a bug in https://github.com/haypo/trollius/issues/4
Until it is resolved you can temporalily resolve it by installing an unofficial development version from ludios by doing:
pip install -U git+https://github.com/ludios/trollius#f757a29815c2c9f5c3a691135ff758649fe84098#egg=trollius
Remember that this is a temporary and unofficial solution only. So hit the "subscribe" button on the issue page: https://github.com/haypo/trollius/issues/4 to subscribe to notifications. When the issue is officially resolved, use the official solution.

Resources