If I change the folder, why is the "ModuleNotFouldError" happened? - python

My environment is Windows10, and I installed python3.6, tensorflow, and anaconda.
There is no error in the installation.
If I run the "command prompt" (not use anaconda), I can success to run tensorflow.
However, if I use anaconda, a problem is coming.
1st: If I run anaconda prompt and import tensorflow by python, no problem.
2nd: If I change the folder and import tensorflow, the error message "ModuleNotFouldError" is coming.
Why I change the path, I cannot import a module?
History is below.
(c:\Users\**Username**\Anaconda3) c:\Users\**Username**\>python
Python 3.6.0 |Anaconda 4.3.0 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits", or "license" for more information
>>>import tensorflow
>>>exit()
(c:\Users\**Username**\Anaconda3) c:\Users\**Username**\>cd workspace
(c:\Users\**Username**\Anaconda3) c:\Users\**Username**\workspace>python
Python 3.6.0 |Anaconda 4.3.0 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC 1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits", or "license" for more information
>>>import tensorflow
Trackback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'tensorflow'

Related

Different python versions in the same environment of Anaconda

this is what the cmd shows:
C:\Users\74713\Documents>activate root
(root) C:\Users\74713\Documents>python
Python 3.6.2 |Anaconda custom (64-bit)| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
this is what my IDE shows:
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 6.1.0 -- An enhanced Interactive Python.
the first one's version is 3.6.2 while the second one is 3.6.3
and because of that, I meet trouble in import torchtext, which works well in the cmd(3.6.2) while fails in my IDE(3.6.3)

Tensorflow: No module named tensorflow.python

When importing keras into Spyder, I am receiving an error message
ModuleNotFoundError: No module named 'tensorflow.python'
I followed the instruction on Tensorflow page to install it, however it is not working. When importing Tensorflow only, I do not have any error message.
Details about my versions:
Python 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 5.3.0 -- An enhanced Interactive Python.
Thank you for any suggestions!

Running specific python interpreters form command line

When I open CMD (on windows 10) and enter python it initializes python 3.6.0
C:\>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Now I recently also installed 2.7.6 the interpreter. How can I call both version of Python from CMD?
desired outcome
C:\>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> ^Z
C:\>python2.6
Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
You can use Python launcher for Windows:
Python 2.7 interptreter:
C:\> py -2.7
Python 3.6 interpreter:
C:\> py -3.6
You also can run a script with a specific interpreter:
C:\> py -2.7 myScript.py
If its windows machine, to open a specific version of python you can use py from the command line.
example:
py2.7 #for version 2.7
and
py3.6 #for version 3.6
if its a Linux machine you can use the following commands in the command line python
python2.7 #opens version 2.7
and
python3.6 #opens version 3.6

TensorFlow on Windows 10: “not a supported wheel on this platform” error

I was following the guide steps until get the "not a supported wheel on this platform" error. I checked the Anaconda is properly installed with the following version information:
Python 3.6.0 |Anaconda 4.3.0 (64-bit)| (default, Dec 23 2016, 11:57:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anyone know how to solve this?
I think it's only available for Python 3.5.x not 3.6.
You can quickly create a 3.5 environment with conda create -n tensorflow python=3.5

Global Python package

so I have this package. In the cmd I go to hp#HP-PC C:\Users\hp\Documents\scripts:
hp#HP-PC C:\Users\hp\Documents\scripts
> python
Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import toolzz.printer as t
>>> t.printz()
5
Everything is working fine but I want to have a directory in which I could add my scripts and be able to open my cmd->python->import my package and do whatever I am going to do and not get this instead:
hp#HP-PC C:\Users\hp
> python
Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import toolzz
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'toolzz'
>>>
PS: keep in mind I have added the directory scripts to the path and I have global bat files which work
Run
python -m site
It'll list 2 important pieces of information:
The Python module search path, sys.path
The location for the USER_SITE directory, and wether or not this exists.
Python looks for modules along those locations. Put your module in a sys.path location (in one that ends in site-packages preferably), or make sure you created the USER_SITE directory and put your code in there.
And you can always extend the path by setting the PYTHONPATH environment variable.

Categories