I just installed Python 3.6.1 for MacOS X
When I attempt to run the Console(or run anything with Python3), this error is thrown:
AttributeError: mo
If anyone is having this problem when trying to run Jupyter kernel from a virtualenv, just add correct PYTHONPATH
to kernel.json
of your virtualenv kernel (Python 3 in example):
{
"argv": [
"/usr/local/Cellar/python/3.6.5/bin/python3.6",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3 (TensorFlow)",
"language": "python",
"env": {
"PYTHONPATH": "/Users/dimitrijer/git/mlai/.venv/lib/python3.6:/Users/dimitrijer/git/mlai/.venv/lib/python3.6/lib-dynload:/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6:/Users/dimitrijer/git/mlai/.venv/lib/python3.6/site-packages"
}
}
DISCLAIMER: Please, @juanpa.arrivillaga, if you see this answer, feel free to write your own and I will remove this post.
@juanpa.arrivillaga had mentioned above:
Is there a file name enum.py in your working directory, by any chance?
This was the issue I encountered. I was not aware of the enum module on python at the time and had named my test file enum.py
.
Since the file name is the module name, there was a conflict. More info on modules here: https://docs.python.org/2/tutorial/modules.html
I did by using pip install <required-library> --ignore-installed enum34
Once your required library is installed, look for warnings during the build.
I got an Error like this:
Using legacy setup.py install for future, since package 'wheel' is not installed
ERROR: pyejabberd 0.2.11 has requirement enum34==1.1.2, but you'll have enum34 1.1.10 which is incompatible.
To fix this issue now run the command: pip freeze | grep enum34
. This will give you the version of the installed enum34. Now uninstall it by pip uninstall enum34
and reinstall the required version as
pip install "enum34==1.1.20"
I have Python 2 and Python 3 installed on my computer. For some strange reason I have in the sys.path of Python 3 also a path to the sitepackage library directory of Python2 when the re module is called. If I run Python 3 and import enum and print(enum.__file__)
the system does not show this Python 2 path to site-packages. So a very rough and dirty hack is, to directly modify the module in which enum is imported (follow the traceback paths) and insert the following code just before importing enum:
import sys
for i, p in enumerate(sys.path):
if "python27" in p.lower() or "python2.7" in p.lower(): sys.path.pop(i)
import enum
That solved my problem.
Even I had this issue while running python -m grpc_tools.protoc --version Had to set the PYTHONPATH till site-packages and shutdown all the command prompt windows and it worked. Hope it helps for gRPC users.
Håken Lid's answer helped solved my problem (thanks!) , in my case present in Python3.7 running Flask in a Docker container (FROM tiangolo/uwsgi-nginx-flask:python3.7-alpine3.7
).
In my case, enum34
was being installed by another library (pip install smartsheet-python-sdk
).
For those coming with a similar Docker container problem, here is my final Dockerfile (stripped to the relevant lines):
FROM tiangolo/uwsgi-nginx-flask:python3.7-alpine3.7
...
RUN pip install -r requirements.txt
RUN pip uninstall -y enum34
...