使用Anaconda安装OSMnx [英] Installing OSMnx with Anaconda
问题描述
我正在尝试按照此处概述的步骤在我的计算机上以Python 3安装osmnx软件包
I am trying to install the osmnx package in Python 3 on my computer, following the steps outlined here https://geoffboeing.com/2017/02/python-getting-started/. The steps are:
- 下载miniconda,路径为
C:\Anaconda
.我正在使用大学计算机,因此无法执行此操作.但是,Anaconda已安装在这些计算机上,路径为C:\Program Files \Anaconda3
. - 在Anaconda提示中,我尝试了
conda update -n base conda
.但是,这没有完成,因为我没有对目标环境具有写权限"(C:\Program Files \Anaconda3
). - 假设conda是最新的,我忽略了此错误.
conda config --prepend channels conda-forge
运行良好. -
conda create -n ox -c conda-forge osmnx jupyterlab
和conda activate ox
运行良好.在安装的Anaconda Navigator>环境> ox>中列出了OSMnx和jupyterlab. - 在牛环境中,我运行了
jupyter lab
,但这产生了以下错误.很抱歉给我这么大的报价,但我不知道该怎么解释:
- Download miniconda, with the path
C:\Anaconda
. I am unable to do this as I am using university computers. However, Anaconda is already installed on those computers, with the pathC:\Program Files \Anaconda3
. - Within the Anaconda Prompt, I tried
conda update -n base conda
. However, this does not go through because I do not 'have write permission to the target environment' (C:\Program Files \Anaconda3
). - I ignored this error, assuming conda was up to date.
conda config --prepend channels conda-forge
ran fine. conda create -n ox -c conda-forge osmnx jupyterlab
andconda activate ox
ran fine. OSMnx and jupyterlab are listed in Anaconda Navigator>Environments>ox>installed.- In the ox environment, I ran
jupyter lab
, but this gave the following error. I'm sorry for this huge quote, but I don't know how to interpret any of this:
(ox) C:\Users\bm17652>jupyter lab
[I 15:47:48.265 LabApp] Writing notebook server cookie secret to C:\Users\bm17652\AppData\Roaming\jupyter\runtime\notebook_cookie_secret
Traceback (most recent call last):
File "C:\Users\bm17652\.conda\envs\ox\Scripts\jupyter-lab-script.py", line 9, in <module>
sys.exit(main())
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\jupyter_core\application.py", line 268, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
app.initialize(argv)
File "<C:\Users\bm17652\.conda\envs\ox\lib\site-packages\decorator.py:decorator-gen-7>", line 2, in initialize
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\notebook\notebookapp.py", line 1679, in initialize
self.init_webapp()
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\jupyterlab\labapp.py", line 404, in init_webapp
super().init_webapp(*args, **kwargs)
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\notebook\notebookapp.py", line 1442, in init_webapp
self.http_server.listen(port, self.ip)
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\tornado\tcpserver.py", line 152, in listen
self.add_sockets(sockets)
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
self._handlers[sock.fileno()] = add_accept_handler(
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
io_loop.add_handler(sock, accept_handler, IOLoop.READ)
File "C:\Users\bm17652\.conda\envs\ox\lib\site-packages\tornado\platform\asyncio.py", line 99, in add_handler
self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
File "C:\Users\bm17652\.conda\envs\ox\lib\asyncio\events.py", line 501, in add_reader
raise NotImplementedError
NotImplementedError
当我尝试从Anaconda Navigator打开Jupyter Lab并运行import osmnx as ox
时,出现错误没有名为'osmnx'的模块".
When I try to open Jupyter Lab from Anaconda Navigator and run import osmnx as ox
, I get the error "No module named 'osmnx'".
在我看来,Jupyter Lab似乎安装不正确,或与osmnx的连接不正确. 发生这些错误是因为:
To me, it seems like Jupyter Lab is not installed properly, or does not have the proper connections with osmnx. Are these errors occurring because:
- 我没有更新conda吗?
- 我正在从与Anaconda所在的目录(
C:\Program Files \Anaconda3
)不同的目录(C:\Users\bm17652
)中运行代码吗? - 我应该将Anaconda下载到其他路径吗?
- I haven't updated conda?
- I am running the code from a different directory (
C:\Users\bm17652
) than where Anaconda is (C:\Program Files \Anaconda3
)? - Should I download Anaconda to another path?
推荐答案
我遇到了类似的问题.解决方案是创建一个为OSMnx指定的新的完整环境.可以使用
I ran into a similar problem. The solution is to create a new full environment specified for OSMnx. This can be done using
conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx
然后您必须使用以下方法激活该环境:
you then have to activate that environment using:
(base) C:\Users\User>conda activate ox
之后,您可以运行:
(ox) C:\Users\User>python
>>> import osmnx as ox
>>>
测试安装是否成功
这篇关于使用Anaconda安装OSMnx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!