安装

https://zh-v2.d2l.ai/chapter_installation/index.html

安装tensorflow 报错,请问要怎么处理呀?
:guitar:$ pip install tensorflow tensorflow-probability

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

ERROR: Could not find a version that satisfies the requirement tensorflow

ERROR: No matching distribution found for tensorflow

:guitar:$

Hi @jidom

Tensorflow 需要 Python 3.5 to 3.8,并且只支持 64-bit 版本。可以用以下命令再jupyter内检查:

python version:

!python --version

32-bit or 64-bit 版本:

import struct
print(struct.calcsize("P")*8)

hi@goldpiggy 我可能是下载了最新版本的miniconda(Miniconda3-py39_4.9.2-MacOSX-x86_64.sh),python是3.9版本的,我将minicoda3目录删除,重新安装了Miniconda3-latest-MacOSX-x86_64.sh,结果又报错了:
:guitar:$ conda activate d2l
Could not find conda environment: d2l
You can list all discoverable environments with conda info --envs.

:guitar:$ ~/miniconda3/bin/conda init
no change /Users/lingxin/miniconda3/condabin/conda
no change /Users/lingxin/miniconda3/bin/conda
no change /Users/lingxin/miniconda3/bin/conda-env
no change /Users/lingxin/miniconda3/bin/activate
no change /Users/lingxin/miniconda3/bin/deactivate
no change /Users/lingxin/miniconda3/etc/profile.d/conda.sh
no change /Users/lingxin/miniconda3/etc/fish/conf.d/conda.fish
no change /Users/lingxin/miniconda3/shell/condabin/Conda.psm1
no change /Users/lingxin/miniconda3/shell/condabin/conda-hook.ps1
no change /Users/lingxin/miniconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change /Users/lingxin/miniconda3/etc/profile.d/conda.csh
no change /Users/lingxin/.bash_profile
No action taken.
:guitar:$ conda create --name d2l python=3.8 -y
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  • python=3.8

Current channels:

To search for alternate channels that may provide the conda package you’re
looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

Hi @jidom,

试一下 conda install python=3.8.5. 详细见:https://chris35wills.github.io/conda_python_version/

下载官网上的jupyter记事本文件后,打开一些ipynb文件报错:Unreadable Notebook: /home/zhoupengchen/d2l/pytorch/index.ipynb NotJSONError("Notebook does not appear to be JSON: ''...")

例如在打开pytorch/index.ipynb的时候

Stackoverflow is always your friend to debug :slight_smile:

1 Like

请问有解决方法吗?我也遇到同样的问题.而且index.ipynb文件是0kb,是不是这个文件有问题啊?

1 Like

:sob::sob::sob:难受坏了 tensorflow_probability能够安装 但是导入时报错
情况一:
#python 3.8 cuda11.2
#pip install tensorflow==2.4.0 tensorflow-probability==0.12.2
#import tensorflow_probability as tfp 时报错AttributeError: module ‘tensorflow.python.util.tf_inspect’ has no attribute ‘Parameter’

#情况二:
#python 3.8 cuda11.2
#pip install tensorflow==2.5.0 tensorflow-probability==0.12.2
#import tensorflow_probability as tfp 时报错AttributeError: module ‘tensorflow.python.keras.api._v2.keras’ has no attribute

求一解决方案

请问文章中代码支持的tensorflow版本是多少

请问tensorflow 1.x可以运行本书的代码吗

去掉清华的源,直接用pip安装。或者尝试华为的源,资源更新的更快。

我也有同样的问题,很多文件都是0Kb,https://zh-v2.d2l.ai/d2l-zh.zip 下载的

我发现0字节的是这一节没有tf版本的代码

conda命令创建环境报错,python3.8和3.9都试过
报错命令如下
D:\ProgramData\Miniconda3\condabin>conda create --name d2l python=3.8 -y
Collecting package metadata (current_repodata.json): failed

>>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

Traceback (most recent call last):
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\exceptions.py", line 1079, in __call__
    return func(*args, **kwargs)
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
    exit_code = do_call(args, p)
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\cli\conda_argparse.py", line 83, in do_call
    return getattr(module, func_name)(args, parser)
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\cli\main_create.py", line 41, in execute
    install(args, parser, 'create')
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\cli\install.py", line 261, in install
    unlink_link_transaction = solver.solve_for_transaction(
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\solve.py", line 114, in solve_for_transaction
    unlink_precs, link_precs = self.solve_for_diff(update_modifier, deps_modifier,
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\solve.py", line 157, in solve_for_diff
    final_precs = self.solve_final_state(update_modifier, deps_modifier, prune, ignore_pinned,
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\solve.py", line 262, in solve_final_state
    ssc = self._collect_all_metadata(ssc)
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\common\io.py", line 88, in decorated
    return f(*args, **kwds)
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\solve.py", line 425, in _collect_all_metadata
    index, r = self._prepare(prepared_specs)
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\solve.py", line 1020, in _prepare
    reduced_index = get_reduced_index(self.prefix, self.channels,
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\index.py", line 288, in get_reduced_index
    new_records = SubdirData.query_all(spec, channels=channels, subdirs=subdirs,
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\subdir_data.py", line 140, in query_all
    result = tuple(concat(executor.map(subdir_query, channel_urls)))
  File "D:\ProgramData\Miniconda3\lib\concurrent\futures\_base.py", line 608, in result_iterator
    yield fs.pop().result()
  File "D:\ProgramData\Miniconda3\lib\concurrent\futures\_base.py", line 445, in result
    return self.__get_result()
  File "D:\ProgramData\Miniconda3\lib\concurrent\futures\_base.py", line 390, in __get_result
    raise self._exception
  File "D:\ProgramData\Miniconda3\lib\concurrent\futures\thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\subdir_data.py", line 132, in <lambda>
    subdir_query = lambda url: tuple(SubdirData(Channel(url), repodata_fn=repodata_fn).query(
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\subdir_data.py", line 145, in query
    self.load()
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\subdir_data.py", line 210, in load
    _internal_state = self._load()
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\subdir_data.py", line 375, in _load
    raw_repodata_str = fetch_repodata_remote_request(
  File "D:\ProgramData\Miniconda3\lib\site-packages\conda\core\subdir_data.py", line 701, in fetch_repodata_remote_request
    resp = session.get(join_url(url, filename), headers=headers, proxies=session.proxies,
  File "D:\ProgramData\Miniconda3\lib\site-packages\requests\sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "D:\ProgramData\Miniconda3\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\ProgramData\Miniconda3\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "D:\ProgramData\Miniconda3\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "D:\ProgramData\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
    self._prepare_proxy(conn)
  File "D:\ProgramData\Miniconda3\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
    conn.connect()
  File "D:\ProgramData\Miniconda3\lib\site-packages\urllib3\connection.py", line 359, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "D:\ProgramData\Miniconda3\lib\site-packages\urllib3\connection.py", line 500, in _connect_tls_proxy
    return ssl_wrap_socket(
  File "D:\ProgramData\Miniconda3\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "D:\ProgramData\Miniconda3\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "D:\ProgramData\Miniconda3\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "D:\ProgramData\Miniconda3\lib\ssl.py", line 997, in _create
    raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname

$ D:\ProgramData\Miniconda3\Scripts\conda-script.py create --name d2l python=3.8 -y

environment variables:
CIO_TEST=
CONDA_BAT=D:\ProgramData\Miniconda3\condabin\conda.bat
CONDA_EXE=D:\ProgramData\Miniconda3\condabin…\Scripts\conda.exe
CONDA_EXES=“D:\ProgramData\Miniconda3\condabin…\Scripts\conda.exe”
CONDA_ROOT=D:\ProgramData\Miniconda3
CONDA_SHLVL=0
CURL_CA_BUNDLE=
HOMEPATH=\Users\zbb
PATH=D:\ProgramData\Miniconda3;D:\ProgramData\Miniconda3\Library\mingw-w64
bin;D:\ProgramData\Miniconda3\Library\usr\bin;D:\ProgramData\Miniconda
3\Library\bin;D:\ProgramData\Miniconda3\Scripts;D:\ProgramData\Minicon
da3\bin;D:\ProgramData\Miniconda3\condabin;D:\ProgramData\Miniconda3;D
:\ProgramData\Miniconda3\Library\mingw-w64\bin;D:\ProgramData\Minicond
a3\Library\usr\bin;D:\ProgramData\Miniconda3\Library\bin;D:\ProgramDat
a\Miniconda3\Scripts;C:\Program Files (x86)\Razer Chroma
SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Program Files
(x86)\VMware\VMware Workstation\bin;C:\Program Files
(x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast
\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Window
s\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Pro
gram Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program
Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Windows\system32\config\sys
temprofile\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\system32;C:
WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell
\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Microsoft SQL
Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files
(x86)\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft
SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL
Server\150\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\150\D
TS\Binn;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Micros
oft\WindowsApps;D:\Program
Files\MATLAB\R2021b\runtime\win64;D:\Program
Files\MATLAB\R2021b\bin;C:\Program Files\MySQL\MySQL Shell
8.0\bin;C:\Users\zbb\AppData\Local\Microsoft\WindowsApps;C:\Program
Files\Azure Data
Studio\bin;C:\Users\zbb\AppData\Local\GitHubDesktop\bin
PSMODULEPATH=%ProgramFiles%\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPo
werShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL
Server\150\Tools\PowerShell\Modules
REQUESTS_CA_BUNDLE=
SSL_CERT_FILE=

 active environment : None
        shell level : 0
   user config file : C:\Users\zbb\.condarc

populated config files :
conda version : 4.10.3
conda-build version : not installed
python version : 3.9.5.final.0
virtual packages : __cuda=11.5=0
__win=0=0
__archspec=1=x86_64
base environment : D:\ProgramData\Miniconda3 (writable)
conda av data dir : D:\ProgramData\Miniconda3\etc\conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch

      package cache : D:\ProgramData\Miniconda3\pkgs
                      C:\Users\zbb\.conda\pkgs
                      C:\Users\zbb\AppData\Local\conda\conda\pkgs
   envs directories : D:\ProgramData\Miniconda3\envs
                      C:\Users\zbb\.conda\envs
                      C:\Users\zbb\AppData\Local\conda\conda\envs
           platform : win-64
         user-agent : conda/4.10.3 requests/2.25.1 CPython/3.9.5 Windows/10 Windows/10.0.22000
      administrator : False
         netrc file : None
       offline mode : False

An unexpected error has occurred. Conda has prepared the above report.

Upload did not complete.

解决了,用conda clean -i命令清除安装包,再使用对应正确的python版本号进行创建环境就可以了

请问是否支持3090显卡,各个依赖版本是否需要调整

我使用pip安装D2L包,版本是安装教程上建议的0.17.3 , 但是安装失败,显示找不到pandas 1.2.2的包,我用的镜像源是阿里云的,里面的pandas最高版本也才1.1.5,请问哪里的源能安装这个版本的,或者能不能安装低版本的d2l 包,能兼容低版本pandas的?

tensorflow的安装方式支持带m1芯片的mac吗

m1 mac 安装 d2l 总失败: