<p><strong>TL;博士:</strong></p>
<p>问题:安装路径过长</p>
<p>解决方案:在路径较短的文件夹(例如<code>C:/my_py_packages/some_package</code>)中安装所需的python包(在我的例子中是tensorflow),或者将注册表值<code>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled</code>设置为<code>1</code><a href="https://docs.python.org/3.7/using/windows.html" rel="nofollow noreferrer">as mentioned here</a>。</p>
<p><strong>原始答案:</strong>
我在尝试安装<code>tensorflow</code>库时遇到了这种错误。我的错误如下:</p>
<blockquote>
<p>Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\moj
ifajlovi\faks\11master\1semestar\siap-sistemizaistrazivanjeianalizupodataka_(datamining)\projek
at\rad\venvs\siap_venv\Lib\site-packages\tensorflow_estimator\python\estimator\canned\line
ar_optimizer\python\utils\__pycache__\sharded_mutable_dense_hashtable.cpython-37.pyc'</p>
</blockquote>
<p>因此,<code>__pycache__</code>目录中没有<code>sharded_mutable_dense_hashtable.cpython-37.pyc</code>文件。但是,<code>sharded_mutable_dense_hashtable.cpython-37.pyc</code>文件在<code>utils</code>目录中(这是<code>__pycache__</code>目录的父目录)。</p>
<p>这就是为什么我试图手动复制<code>sharded_mutable_dense_hashtable.cpython-37.pyc</code>目录中的<code>__pycache__</code>文件。当我尝试这样做时,我有一个复制错误,它指出路径太长,所以无法将文件放入目录中。</p>
<p>因此,<strong>解决方案:</p>
<p>在路径较短的文件夹(例如<code>C:/my_py_packages/some_package</code>)中安装所需的python包(在我的例子中是tensorflow),或者将注册表值<code>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled</code>设置为<code>1</code><a href="https://docs.python.org/3.7/using/windows.html" rel="nofollow noreferrer">as mentioned here</a>。</p>