Tensorflow importing crashes Python without any error on Windows - python

Yesterday I was trying to solve matplotlib problems on Windows, which included solving from matplotlib import ft2font error. I have added HDF5_DISABLE_VERSION_CHECK=2 for that. But today I found, that tensorflow doesn't work anymore:
> python
Python 3.5.5 |Anaconda, Inc.| (default, Apr 7 2018, 04:52:34) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>
It thinks 30 seconds, then exits Python without any error.
Where can I see logs or crashdumps or something?

If you try import h5py, and get ImportError: DLL load failed, you probably have some problem as mine. Try:
Uninstall h5py via anaconda navigator, some relative libs (tensorflow) will be uninstalled as well.
Go VM path in anaconda installation, D:\Anaconda\envs\YOUR_VM\Lib\site-packages, delete h5py and h5py-2.8.0-py3.6.egg-info folders
Reinstall tensorflow or tensorflow-gpu

Related

Python 3.6.x + Windows: Interpreter just shuts down for any external library

Due to external dependencies I need to run python 3.6.x (I know it is EOL) on Windows.
However, any external library causes the interpreter to just silently quit.
As an example I have installed numpy in the following way
py -m pip install numpy
And then running Python through PowerShell:
PS C:\Users\USER> py
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
PS C:\Users\USER>
As soon as I run import numpy the python interpreter simply silently returns.
I have tried to install every python 3.6.x available from Pythons official website, and the issue persists.
I fully removed old versions of python between each install.
I cannot find any error logs or anything.
What can be the issue here and how can I debug further?
Any internal library (that I have tried) works
I have tried with the following libraries:
Numpy
Tensorflow
Protobuf
matplotlib
scipy
pandas
nose
sympy

ModuleNotFoundError when using Visual Studio Code

I am using a machine I inherited with an Anaconda 3 installation on it. I am trying to complete a Python course, which is my first foray into Python ever. When I open a Python interpreter in Command Prompt or PowerShell, and I run the following line, it executes without error.
(base) PS D:\ProgramData\Anaconda3\Scripts> py
Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xlsxwriter
Somehow Anaconda is integrated with VS Code, yet when I try and import xlsxwriter in this window, I get the error:
ModuleNotFoundError: No module named 'xlslwriter'
When this Python interpreter window opens, it shows the following:
Jupyter Server URI: http://localhost:8889/?token=b8a07e61e603f9dae0ee599198ac33f68d3f398036f6af0e
Python version:
3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
(6, 0, 1)
D:\\ProgramData\\Anaconda3\\envs\\py37\\python.exe
If I try installing xlsxwriter with pip, I get a message that
Requirement already satisfied: xlsxwriter in d:\programdata\anaconda3\lib\site-packages (1.2.8)
I'm not asking for an instant answer, but guidance on how I can diagnose and correct this problem. Why is the module available to some interpreters (Command Prompt and PowerShell, and Jupyter Notebook) and not available in the VS Code interpreter? How can I use VS Code and or Python functionality to learn about the config of the current environment and such things?
Based on advice given in this answer, I ran the command
!pip install xlsxwriter
in the VS Code interpreter, and finally, the module was available for import.

ModuleNotFoundError: No module named 'tqdm'

Can not run my awesome.py cause:
ModuleNotFoundError: No module named 'tqdm'
(incaelum) C:\Users\inc\Desktop\pruebas\STR_SEARCH>python
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:05:27) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tqdm
>>>
As u can see i can run python and import tqdm with no errors
I used pip, pip3, conda to install tqdm inside my envoriment:
installation suscesful
I also installed tqdm from anaconda environment manager. no errors as well
but when i run the program i get always the same:
ModuleNotFoundError: No module named 'tqdm'
Am running the py file from my envoriment and getting same error.
Anyone can deal with this?

python module import error when running, while imported fine in interactive mode

I've created a clean python3.6 virtualenv in a native python2 environment via anaconda3, and I'm able to import some module in the interactive mode:
$ python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from skimage.transform import resize
>>>
however, this seems to break when I run in a non-interactive mode by calling:
(py3)$ python filename.py
...
File "path_to_module.py", line 6, in <module>
from skimage.transform import resize
...
ImportError: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by path_to_pyenv/anaconda3/lib/python3.6/site-packages/matplotlib/_path.cpython-36m-x86_64-linux-gnu.so)
Note this error does not occur exclusively by importing this particular skimage module, so i guess this is a generic error.
Anyone has an idea how to fix this?
Thanks!
turns out that the native matplotlib coming with Anaconda was outdated, so i fixed this error by upgrading it:
pip install matplotlib --upgrade

Python 2.7 Anaconda2 installed in windows

My Python 2 environmental path:
C:\Python27
C:\Python27\Scripts
My Python 3 environmental path:
C:\Python35
C:\Python35\Scripts
I set the environmental path for Anaconda2
C:\Users\User\Anaconda2\Scripts
C:\Users\User\Anaconda2
But when i typed python to enter the shell in cmd (C:\Users\user)
Importing the module of Anaconda like numpy or matplotlib
C:\Users\User>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named numpy
C:\Users\User>cd Anaconda2
C:\Users\User\Anaconda2>python
Python 2.7.12 |Anaconda 4.1.1 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy
>>>
So i don't know
1.Why my module can't import while not in Anaconda2
2.It is said that the path of Python2 will overrdie the Python,so how to enter in the Python35 shell?
thanks everybody
Each Python installation has its own libraries. As you will see, you are not running the same Python 2.7 interpreter when you run with Anaconda active as you are without (I assume that's either the system Python or one you installed yourself).
Libraries installed in one interpreter aren't available to others. You should consider learning about conda environments to allow you to manage multiple projects easily.
The command deactivate should terminate the Anaconda environment, and if the Python 3 interpreter is first on your PATH you should then be able to run it. Another way would be to explicitly use the command
C:\Python35\python
which should work even with Anaconda active.
Caution: it's a long time since I used Windows, and I don't have current information on getting multiple Pythons to live happily together on Windows.

Categories