ImportError:在OSX中没有为Python3.4.1命名为'numpy'的模块

时间:2016-08-04 20:36:57

标签: python macos numpy pip easy-install

我必须将Python3.4.1用于软件,因此我从源代码安装它。现在我使用easy_install安装了pip后出现了这个错误:

bash-4.3$ python
Python 3.4.1 (default, Aug  4 2016, 13:53:56)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>>

>>> sys.executable
'/usr/local/bin/python3'
>>> import pip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'pip'
    bash-4.3$ python3 -m pip install --user numpy
    /usr/local/bin/python3: Error while finding spec for 'pip.__main__' (<class 'ImportError'>: cannot import name 'HTTPSHandler'); 'pip' is a package and cannot be directly executed
bash-4.3$ python -m pip install --user numpy
/usr/local/bin/python3: Error while finding spec for 'pip.__main__' (<class 'ImportError'>: cannot import name 'HTTPSHandler'); 'pip' is a package and cannot be directly executed
bash-4.3$ pip -V
pip 8.1.2 from /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (python 3.4)
bash-4.3$ python --version
Python 3.4.1

如何在OSX EL Capitan中为此版本的Python安装numpy?

bash-4.3$ pip freeze | grep numpy
numpy==1.11.1

更新:我甚至尝试过这种方法,但仍无法导入:

bash-4.3$ wget https://bootstrap.pypa.io/get-pip.py
--2016-08-04 15:50:04--  https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io... 151.101.44.175
Connecting to bootstrap.pypa.io|151.101.44.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1524722 (1.5M) [text/x-python]
Saving to: ‘get-pip.py’

get-pip.py                                 100%[=====================================================================================>]   1.45M  2.20MB/s    in 0.7s

2016-08-04 15:50:05 (2.20 MB/s) - ‘get-pip.py’ saved [1524722/1524722]

bash-4.3$ sudo python get-pip.py
Password:
The directory '/Users/mona/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/mona/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
  Downloading pip-8.1.2-py2.py3-none-any.whl (1.2MB)
    100% |████████████████████████████████| 1.2MB 820kB/s
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 5.1MB/s
Installing collected packages: pip, wheel
  Found existing installation: pip 1.2.1
    Uninstalling pip-1.2.1:
      Successfully uninstalled pip-1.2.1
Successfully installed pip-8.1.2 wheel-0.29.0

使用easy_install

bash-4.3$ sudo easy_install pip
Searching for pip
Best match: pip 8.1.2
Adding pip 8.1.2 to easy-install.pth file
Installing pip3 script to /Library/Frameworks/Python.framework/Versions/3.4/bin
Installing pip3.5 script to /Library/Frameworks/Python.framework/Versions/3.4/bin
Installing pip script to /Library/Frameworks/Python.framework/Versions/3.4/bin

Using /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
bash-4.3$ python
Python 3.4.1 (default, Aug  4 2016, 13:53:56)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'pip'

还有我在另一篇SO帖子中看到的另一个建议:

bash-4.3$ python3 -m pip
/usr/local/bin/python3: No module named pip

0 个答案:

没有答案