enter image description here
PS C:\WINDOWS\system32> python
Python 3.7.0a2 (v3.7.0a2:f7ac4fe, Oct 17 2017, 17:06:29) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> import numpy
PS C:\WINDOWS\system32> python
Python 3.7.0a2 (v3.7.0a2:f7ac4fe, Oct 17 2017, 17:06:29) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
PS C:\WINDOWS\system32>
I can not import the mentioned modules however it is not giving any error as well. Even in small program if I import any of these 3 the program just ends without doing anything.
I have only one installation of Python. No other verison.
Update:
PS C:\WINDOWS\system32> pip freeze
boto==2.49.0
boto3==1.9.115
botocore==1.12.115
bz2file==0.98
certifi==2019.3.9
chardet==3.0.4
docutils==0.14
gensim==3.7.1
idna==2.8
jmespath==0.9.4
nltk==3.4
numpy==1.16.2
python-dateutil==2.8.0
requests==2.21.0
s3transfer==0.2.0
scipy==1.2.1
singledispatch==3.4.0.3
six==1.12.0
smart-open==1.8.0
urllib3==1.24.1
PS C:\WINDOWS\system32> python
Python 3.7.0a2 (v3.7.0a2:f7ac4fe, Oct 17 2017, 17:06:29) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print(numpy.__version__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'numpy' is not defined
>>> exit()
PS C:\WINDOWS\system32>
Maybe I am reading what you have given incorrectly, but the way you have given, you haven’t done any “import numpy” in that Python session before accessing numpy.version. Please confirm.
Related
Recently, I tried to install pypoetry on my windows. The python I used was installed from MS store. And I found something strange.
C:\Users\Liu.D.H>where python
C:\Users\Liu.D.H\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Users\Liu.D.H\anaconda3\python.exe
C:\Users\Liu.D.H>C:\Users\Liu.D.H\anaconda3\python.exe
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.realpath("C:/Users/Liu.D.H/AppData/Roaming/pypoetry")
'C:\\Users\\Liu.D.H\\AppData\\Roaming\\pypoetry'
>>> exit()
C:\Users\Liu.D.H>python
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.realpath("C:/Users/Liu.D.H/AppData/Roaming/pypoetry")
'C:\\Users\\Liu.D.H\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Roaming\\pypoetry'
>>> exit()
C:\Users\Liu.D.H>
I also tried the realpath of node.
C:\Users\Liu.D.H>node
Welcome to Node.js v14.18.1.
Type ".help" for more information.
> fs.realpathSync("C:/Users/Liu.D.H/AppData/Roaming/pypoetry")
Uncaught:
Error: ENOENT: no such file or directory, lstat 'C:\Users\Liu.D.H\AppData\Roaming\pypoetry'
at Object.realpathSync (fs.js:1800:7) {
errno: -4058,
syscall: 'lstat',
code: 'ENOENT',
path: 'C:\\Users\\Liu.D.H\\AppData\\Roaming\\pypoetry'
}
>
So, the %APPDATA%/sub_path location in windows is process-dependent?
I'm installing package whl with pip in virtual enviorment.
PS C:\Users\Project> .\venv37\Scripts\activate
(venv37) PS C:\Users\Project> pip install .\vtk-9.0.1-cp37-cp37m-win_amd64.whl
Processing c:\users\project\vtk-9.0.1-cp37-cp37m-win_amd64.whl
Installing collected packages: vtk
Successfully installed vtk-9.0.1
and import works.
(venv37) PS C:\Users\Project> python
Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
>>> exit()
(venv37) PS C:\Users\Project> deactivate
Now I try to execute it from Python Interpreter in venv.
PS C:\Users\Project> .\venv37\Scripts\activate
(venv37) PS C:\Users\Project> .\venv37\Scripts\python.exe
Python 3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'vtk'
>>>
And it doesn't work. What is my mistake?
Actually I already installed tensorflow by using
$ pip install tensorflow
and it works well when I use
$ python
Python 2.7.15 (default, Jul 23 2018, 21:27:06)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import tensorflow
>>>
but when I use python3 on command line
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>>
it shows an error, and it shows the same error when I use IDLE
use
pip3 install tensorflow
pip installs to default python directory. pip3 installs to python3
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
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'