【发布时间】:2021-06-26 05:54:53
【问题描述】:
在关注this tutorial by tds 时,我决定通过 pipenv 来做,因为我在 macos 上。我设法完成了大部分工作,但我一直遇到一个错误,表明我不明白 pipenv 如何设置环境。具体来说,它是如何运行脚本的。即使在 pipenv shell 中,它似乎也恢复到依赖我的系统 python (2.7)。 (parse_gpx.py是主要的python文件,2021-0622run.gpx是要分析的gpx格式文件)
- “pipenv shell”然后运行命令“pipenv run python parse_gpx.py 2021-0622run.gpx”会出现以下错误:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 25, in <module>
from pandas import hashtable, tslib, lib
ImportError: dlopen(/Library/Python/2.7/site-packages/pandas/hashtable.so, 2): Symbol not found: _PyCObject_Type
Referenced from: /Library/Python/2.7/site-packages/pandas/hashtable.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/pandas/hashtable.so
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "parse_gpx.py", line 5, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 31, in <module>
"extensions first.".format(module))
ImportError: C extension: dlopen(/Library/Python/2.7/site-packages/pandas/hashtable.so, 2): Symbol not found: _PyCObject_Type
Referenced from: /Library/Python/2.7/site-packages/pandas/hashtable.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/pandas/hashtable.so not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
- “pipenv run python parse_gpx.py 2021-0622run.gpx”生成预期的表。
我的问题是:为什么“pipenv shell”看起来在系统 python 中而不是留在它自己的“盒子”中?这不是 pipenv 的全部意义吗?有可能我配置错了吗?我确实在设置它时遇到了一些问题(包括双重安装和其他事情),这就是为什么我不确定这种行为是设计使然,还是我之前的拙劣安装的残余。
任何帮助指出我解释正在发生的事情的文档将不胜感激!
最后,如果发错地方了,抱歉。我试着寻找最好的地方来问这个问题,并检查是否有人以前问过这个问题。
谢谢!
【问题讨论】: