[英]Fixing “pyproj import _datadir” error: specified module could not be found
I am doing a Python project in Jupyter Notebook.我在 Jupyter Notebook 中做一个 Python 项目。 Everything was fine until I tried to use Basemap, which I have installed in the Anaconda terminal for my environment using:
在我尝试使用 Basemap 之前,一切都很好,我已将其安装在 Anaconda 终端中,用于我的环境,使用:
conda install -c anaconda basemap
I attempt to import:我尝试导入:
from mpl_toolkits.basemap import Basemap as Basemap
which gives the error:这给出了错误:
ImportError Traceback (most recent call last)
<ipython-input-17-c19d6352b4bd> in <module>
3 #from pyproj import _datadir
4 #from pyproj import _datadir, datadir
----> 5 from mpl_toolkits.basemap import Basemap as Basemap
~\Anaconda3\envs\name_of_my_env\lib\site-packages\mpl_toolkits\basemap\__init__.py in <module>
44 from matplotlib.lines import Line2D
45 from matplotlib.transforms import Bbox
---> 46 import pyproj
47 from mpl_toolkits.axes_grid1 import make_axes_locatable
48 from matplotlib.image import imread
~\Anaconda3\envs\name_of_my_env\lib\site-packages\pyproj\__init__.py in <module>
48 import warnings
49
---> 50 from pyproj import _datadir
51 from pyproj._list import ( # noqa: F401
52 get_angular_units_map,
ImportError: DLL load failed: The specified module could not be found.
Thinking there was an issue with pyproj I installed:认为我安装的 pyproj 存在问题:
conda install -c conda-forge pyproj
conda install -c conda-forge/label/broken pyproj
This didn't fix anything so I installed:这没有解决任何问题,所以我安装了:
conda install -c conda-forge geopandas
for good measure, but even import geopandas
does not work, giving:为了很好的衡量,但即使
import geopandas
也不起作用,给出:
ImportError Traceback (most recent call last)
<ipython-input-18-5f9c797680a3> in <module>
1 import pandas as pd
----> 2 import geopandas
3 #from pyproj import _datadir
4 #from pyproj import _datadir, datadir
5 from mpl_toolkits.basemap import Basemap as Basemap
~\Anaconda3\envs\name_of_my_env\lib\site-packages\geopandas\__init__.py in <module>
----> 1 from geopandas.geoseries import GeoSeries # noqa
2 from geopandas.geodataframe import GeoDataFrame # noqa
3 from geopandas.array import _points_from_xy as points_from_xy # noqa
4
5 from geopandas.io.file import read_file # noqa
~\Anaconda3\envs\name_of_my_env\lib\site-packages\geopandas\geoseries.py in <module>
7 from pandas.core.internals import SingleBlockManager
8
----> 9 from pyproj import CRS, Transformer
10 from shapely.geometry.base import BaseGeometry
11 from shapely.ops import transform
~\Anaconda3\envs\name_of_my_env\lib\site-packages\pyproj\__init__.py in <module>
48 import warnings
49
---> 50 from pyproj import _datadir
51 from pyproj._list import ( # noqa: F401
52 get_angular_units_map,
ImportError: DLL load failed: The specified module could not be found.
Clearly, the error is with pyproj import _datadir, but I have no clue how to fix this.显然,错误是 pyproj import _datadir,但我不知道如何解决这个问题。
I know it's not an ideal solution, but the only way I could manage to solve this issue was to completely uninstall Anaconda , then reinstall Anaconda and and my packages in a new environment.我知道这不是一个理想的解决方案,但我能设法解决这个问题的唯一方法是完全卸载Anaconda ,然后在新环境中重新安装 Anaconda 和我的包。 Seeing as you posted two days ago, I'm sure you've probably already resorted to this by now.
看到您两天前发布的内容,我敢肯定您现在可能已经诉诸于此。
Things I tried before the reinstall:我在重新安装之前尝试过的事情:
conda update conda
conda install anaconda=2020.02
pyproj
via conda install -c conda-forge pyproj
.pyproj
conda install -c conda-forge pyproj
。 During installation, I got a warning that I should manually remove a "libssl-1_1-x64.dll" file because conda apparently could not do it. I did not get this error in an environment that used geopandas
0.6.3, but I needed to update to 0.7.0 to use the geopandas.clip()
function.在使用
geopandas
0.6.3 的环境中我没有收到此错误,但我需要更新到 0.7.0 才能使用geopandas.clip()
function。 After this update is when I started experiencing this problem with pyproj
.在此更新之后,我开始遇到
pyproj
的这个问题。 Again, not an ideal answer, but I was able to "solve" the problem in my case by uninstalling and reinstalling.同样,这不是一个理想的答案,但我能够通过卸载和重新安装来“解决”我的问题。
Ran into this problem myself.我自己遇到了这个问题。 Here is what fixed it for me.
这是为我解决的问题。
When pyproj
looks for the _datadir
module, it is looking for your-env/Lib/site-packages/pyproj/_datadir.pyd
当
pyproj
查找_datadir
模块时,它正在查找your-env/Lib/site-packages/pyproj/_datadir.pyd
When I browsed to that directory, I found that all of the *.pyd
files were named *.cp38-win_amd64.pyd
This seems common enough in other packages, and perhaps someone with greater expertise can speak to why it does or doesn't appear in various package filenames.当我浏览到那个目录时,我发现所有的
*.pyd
文件都被命名为*.cp38-win_amd64.pyd
这在其他包中似乎很常见,也许有更专业的人可以说出为什么这样做或不这样做出现在各种 package 文件名中。
Regardless, deleting that bit of text between the two .
无论如何,删除两者之间的那一点文本
.
characters seemed to do it, ie, renaming _datadir.cp38-win_amd64.pyd
> _datadir.pyd
.字符似乎做到了,即重命名
_datadir.cp38-win_amd64.pyd
> _datadir.pyd
。
I tested a number of operations using geopandas
after editing the filenames, and everything worked as expected.在编辑文件名后,我使用
geopandas
测试了一些操作,一切都按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.