tensorflow使用问题-如何查看tensorflow的安装路径和安装版本 (含扩展安装路径)

一.tensorflow 安装路径和安装版本查询:

(win10,python3.5,tensorflow1.05)
使用命令:

PS C:\Users\a1104> python
Python 3.5.2rc1 (v3.5.2rc1:68feec6488b2+, Jun 12 2016, 08:56:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__   #双下划线
'1.5.0'
>>>
>>> tf.__path__      #双下划线
['C:\\python\\lib\\site-packages\\tensorflow']
>>>

注意:上面是双下划线

错误命令演示

>>> import tensorflow as tf
>>> tf._ _version_ _
  File "<stdin>", line 1
    tf._ _version_ _          #此处多加了空格
                 ^
SyntaxError: invalid syntax
>>> import tensorflow as tf
>>> tf._path_                  #此处只有一个下划线
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute '_path_'
>>> import tensorflow as tf
>>> tf._version_                #此处只有一个下划线
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute '_version_'

扩展:

二.如何查看python的安装路径:

PS C:\Users\a1104> python
Python 3.5.2rc1 (v3.5.2rc1:68feec6488b2+, Jun 12 2016, 08:56:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', 'C:\\python\\python35.zip', 'C:\\python\\DLLs', 'C:\\python\\lib', 'C:\\python', 'C:\\python\\lib\\site-packages']

如何查看python中安装的模块:##

如何想知道自己import的模块所在的位置可以用这种方法,和方法一类似

>>> import tensorflow
>>> print tensorflow.__file__
  File "<stdin>", line 1
    print tensorflow.__file__
                   ^
SyntaxError: Missing parentheses in call to 'print'
>>> print (tensorflow.__file__)
C:\python\lib\site-packages\tensorflow\__init__.py
>>>

如何查看python中已经安装的库:

>>> help('modules')

Please wait a moment while I gather a list of all available modules...

__future__          antigravity         idlelib             shlex
_ast                argparse            imaplib             shutil
_bisect             array               imghdr              signal
_bootlocale         ast                 imp                 site
_bz2                asynchat            importlib           six
_codecs             asyncio             inspect             smtpd
_codecs_cn          asyncore            io                  smtplib
_codecs_hk          atexit              ipaddress           sndhdr
_codecs_iso2022     audioop             itertools           socket
_codecs_jp          base64              json                socketserver
_codecs_kr          bdb                 keyword             sqlite3
_codecs_tw          binascii            lib2to3             sre_compile
_collections        binhex              linecache           sre_constants
_collections_abc    bisect              locale              sre_parse
_compat_pickle      bleach              logging             ssl
_compression        builtins            lzma                stat
_csv                bz2                 macpath             statistics
_ctypes             cProfile            macurl2path         string
_ctypes_test        calendar            mailbox             stringprep
_datetime           cgi                 mailcap             struct
_decimal            cgitb               markdown            subprocess
_dummy_thread       chunk               marshal             sunau
_elementtree        cmath               math                symbol
_functools          cmd                 mimetypes           symtable
_hashlib            code                mmap                sys
_heapq              codecs              modulefinder        sysconfig
_imp                codeop              msilib              tabnanny
_io                 collections         msvcrt              tarfile
_json               colorsys            multiprocessing     telnetlib
_locale             compileall          netrc               tempfile
_lsprof             concurrent          nntplib             tensorboard
_lzma               configparser        nt                  tensorflow
_markupbase         contextlib          ntpath              test
_md5                copy                nturl2path          textwrap
_msi                copyreg             numbers             this
_multibytecodec     crypt               numpy               threading
_multiprocessing    csv                 opcode              time
_opcode             ctypes              operator            timeit
_operator           curses              optparse            tkinter
_osx_support        datetime            os                  token
_overlapped         dbm                 parser              tokenize
_pickle             decimal             pathlib             trace
_pydecimal          difflib             pdb                 traceback
_pyio               dis                 pickle              tracemalloc
_random             distutils           pickletools         tty
_sha1               doctest             pip                 turtle
_sha256             dummy_threading     pipes               turtledemo
_sha512             easy_install        pkg_resources       types
_signal             email               pkgutil             typing
_sitebuiltins       encodings           platform            unicodedata
_socket             ensurepip           plistlib            unittest
_sqlite3            enum                poplib              urllib
_sre                errno               posixpath           uu
_ssl                faulthandler        pprint              uuid
_stat               filecmp             profile             venv
_string             fileinput           pstats              warnings
_strptime           fnmatch             pty                 wave
_struct             formatter           py_compile          weakref
_symtable           fractions           pyclbr              webbrowser
_testbuffer         ftplib              pydoc               werkzeug
_testcapi           functools           pydoc_data          wheel
_testimportmultiple gc                  pyexpat             winreg
_testmultiphase     genericpath         queue               winsound
_thread             getopt              quopri              wsgiref
_threading_local    getpass             random              xdrlib
_tkinter            gettext             re                  xml
_tracemalloc        glob                reprlib             xmlrpc
_warnings           gzip                rlcompleter         xxsubtype
_weakref            hashlib             runpy               zipapp
_weakrefset         heapq               sched               zipfile
_winapi             hmac                select              zipimport
abc                 html                selectors           zlib
absl                html5lib            setuptools
aifc                http                shelve

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".

>>>

猜你喜欢

转载自blog.csdn.net/qq_39782872/article/details/80566426