Keras installed but not working - windows

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

Related

Airflow Installation issue| setproctitle

I Have followed the below steps for airflow installation and have successfully installed but am unable to run any commands which start with airflow, even to check the version. Any help is appreciated.
python3.9 -m venv airflowenv ,
source airflowenv/bin/activate export ,
AIRFLOW_HOME=~/airflow ,
echo $AIRFLOW_HOME ,
pip install --upgrade pip ,
pip install apache-airflow==1.10.15 ,
airflow initdb.
This is the error am receiving:
Traceback (most recent call last):
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/bin/airflow", line 25, in <module>
from airflow.configuration import conf
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/__init__.py", line 50, in <module>
from airflow.models import DAG # noqa: E402
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/models/__init__.py", line 21, in <module>
from airflow.models.baseoperator import BaseOperator, BaseOperatorLink # noqa: F401
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/models/baseoperator.py", line 43, in <module>
from airflow.models.dag import DAG
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/models/dag.py", line 47, in <module>
from airflow.executors import LocalExecutor, get_default_executor
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/executors/__init__.py", line 23, in <module>
from airflow.executors.base_executor import BaseExecutor # noqa
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/executors/base_executor.py", line 24, in <module>
import airflow.utils.dag_processing
File "/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/airflow/utils/dag_processing.py", line 40, in <module>
from setproctitle import setproctitle
ImportError: dlopen(/Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so, 2): Symbol not found: _Py_GetArgcArgv
Referenced from: /Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so
Expected in: flat namespace
in /Users/user_name/Documents/python_learning/airflow/airflowenv/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so```
---------------------------------------------------------------------*********************************************************************
SOLUTION:[Followed these steps to fix the issue]:
Install python3.9 from the python website
python3.9 -m venv envpython
source envpython/bin/activate
export AIRFLOW_HOME=~/airflow
echo $AIRFLOW_HOME
pip install apache-airflow==1.10.15 --constraint https://raw.githubusercontent.com/apache/airflow/constraints-1.10.15/constraints-3.8.txt
airflow initdb
airflow webserver
airflow scheduler
*********************************************************************
If you are on MacOS, you need to install Python 3.8 manually following https://www.python.org/downloads/.
See Import issue for setproctitle on Mac OS,
You should use constraints when installing Airflow. See this link that explains why: https://airflow.apache.org/docs/apache-airflow/stable/installation.html#constraints-files
In your case, the correct command will be:
pip install apache-airflow==1.10.15 --constraint https://raw.githubusercontent.com/apache/airflow/constraints-1.10.15/constraints-3.8.txt

Problem installing importlib on Mac with pip3

Good morning!
Until yesterday I was using python 2.7 and using the following code for writing output files for my scripts:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
But now I'm upgrading my code to python 3.7, so now I need to use importlib.reloadinstead of just reload. However, typing sudo -H pip3 install importlib on my shell gives me the following error:
Collecting importlib
Using cached https://files.pythonhosted.org/packages/31/77/3781f65cafe55480b56914def99022a5d2965a4bb269655c89ef2f1de3cd/importlib-1.0.4.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 6, in <module>
import distutils.core
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 16, in <module>
from distutils.dist import Distribution
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 19, in <module>
from distutils.util import check_environ, strtobool, rfc822_escape
File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/util.py", line 9, in <module>
import importlib.util
ModuleNotFoundError: No module named 'importlib.util'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-3cz_3d6n/importlib/
After looking for solutions I also tried to upgrade setuptools, but that didn't fix my problem.
Many thanks in advance!
importlib at PyPI is an outdated package intended for very old Python versions. For new versions of Python importlib is a module from the standard library, you don't need to install it, it's always available.

sklearn: ImportError: DLL load failed: The specified module could not be found

Ive updated my Python version from 3.5.4 to 3.6.6 (in Anaconda 3) and now the line
from sklearn.metrics.pairwise import cosine_similarity
causes the following error:
Traceback (most recent call last):
File "<ipython-input-3-743ac88bcf9a>", line 1, in <module>
from sklearn.metrics.pairwise import cosine_similarity
File "F:\Program Files\lib\site-packages\sklearn\__init__.py", line 64, in <module>
from .base import clone
File "F:\Program Files\lib\site-packages\sklearn\base.py", line 13, in <module>
from .utils.fixes import signature
File "F:\Program Files\lib\site-packages\sklearn\utils\__init__.py", line 13, in <module>
from .validation import (as_float_array,
File "F:\Program Files\lib\site-packages\sklearn\utils\validation.py", line 22, in <module>
from ..utils.fixes import signature
File "F:\Program Files\lib\site-packages\sklearn\utils\fixes.py", line 83, in <module>
from scipy.special import boxcox # noqa
File "F:\Program Files\lib\site-packages\scipy\special\__init__.py", line 640, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.
Im on Windows 7, 64-bit; previously the line worked fine, and other packages (Pandas, Numpy etc) still work, so it doesn't appear to be a PATH issue as some have suggested.
Ive seen numerous similar questions but all solutions have so far failed. E.g.
roll the installation back to Python 3.5.4,
uninstall & re-install Pandas, Numpy, Scipy and Sklearn, also update MKL/MKL-RT.
The changes suggested in Error when trying to import sklearn modules : ImportError: DLL load failed: The specified module could not be found
were already implemented
Does anyone have any further suggestions (specific to Anaconda etc)?
I solved it, and (in my case) the problem was scipy, not sklearn.
What i did was uninstall scipy with conda: conda remove --force scipy, and then install it with pip: pip install scipy. That worked for me.

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

Pylint Error - no module named astroid

I've recently installed pylint on a windows 7 and when I run it I get the error:
Error executing PyLint: Command failed with error=None, status=1; stderr:
Traceback (most recent call last):
File "C:\Python27\Scripts\pylint", line 3, in <module>
run_pylint()
File "c:\python27\lib\site-packages\pylint\__init__.py", line 20, in run_pylint
from pylint.lint import Run
File "c:\python27\lib\site-packages\pylint\lint.py", line 30, in <module>
from pylint.checkers import utils #pylint: disable=unused-import
File "c:\python27\lib\site-packages\pylint\checkers__init__.py", line 47, in
from pylint.reporters import diff_string
File "c:\python27\lib\site-packages\pylint\reporters__init__.py", line 20, in
from pylint.utils import MSG_TYPES
File "c:\python27\lib\site-packages\pylint\utils.py", line 32, in
from astroid import nodes, Module
ImportError: No module named astroid
I've followed the install instructions as best I can but can't seem to get past this.
Use this link to install pip properly How do I install pip on Windows?
then do the pip install pylint
then do go through this note http://docs.pylint.org/installation.html#note-for-windows-users

Resources