我見過類似的問題,但是沒有給出我的問題的答案。安裝升級到macports後需要.so文件的python包時出錯python 3.5
sudo port install py35-numpy
但是,如果我嘗試安裝需要使用PIP 3 .so文件Python包:如果有一個有效的Macport我最近升級到Mac OS X上安裝Python包使用MacPorts的蟒蛇V3.5工作正常,我收到錯誤。例如,沒有皮塔斯港。首先,我安裝PIP
sudo port install py35-pip
然後我使用PIP安裝pystan到我的Python 3.5目錄
sudo pip3 install --target=/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ pystan
Installing collected packages: Cython, numpy, pystan
Successfully installed Cython-0.24 numpy-1.11.1 pystan-2.9.0.0
不,它實際上並沒有安裝用Cython或numpy的,因爲他們已經在那裏。但後來,當我嘗試運行pystan:
Nate$ ipython
Python 3.5.2 (default, Jun 27 2016, 03:10:38)
Type "copyright", "credits" or "license" for more information.
IPython 5.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import pystan
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-7b354c723dbb> in <module>()
----> 1 import pystan
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pystan/__init__.py in <module>()
7 import logging
8
----> 9 from pystan.api import stanc, stan
10 from pystan.misc import read_rdump, stan_rdump
11 from pystan.model import StanModel
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pystan/api.py in <module>()
10 import hashlib
11
---> 12 import pystan._api # stanc wrapper
13 from pystan._compat import string_types
14 from pystan.model import StanModel
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pystan/_api.so, 2): Symbol not found: _PyBaseString_Type
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pystan/_api.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pystan/_api.so
我看到了同樣的錯誤,當我試圖通過PIP安裝numpy的,同樣一個與netCDF4。
In [2]: import netCDF4
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-f731da2de255> in <module>()
----> 1 import netCDF4
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/netCDF4/__init__.py in <module>()
1 # init for netCDF4. package
2 # Docstring comes from extension module _netCDF4.
----> 3 from ._netCDF4 import *
4 # Need explicit imports for names beginning with underscores
5 from ._netCDF4 import __doc__, __pdoc__
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/netCDF4/_netCDF4.so, 2): Symbol not found: _PyCObject_Type
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/netCDF4/_netCDF4.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/netCDF4/_netCDF4.so
.so文件有什麼問題?或者,對於這個問題,我的電腦?
您是否嘗試過不帶'--target'選項調用'pip3 install'?我希望只要你使用MacPorts安裝的'pip3',它就會把東西安裝在正確的地方。我想知道用'--target'運行它是否會產生一些意想不到的子目錄或其他東西。 – jb326
@ jb326,你可能是對的。請參閱下面的答案。 – Nate