How would I install numpy library on Coding Ground?

ぐ巨炮叔叔 提交于 2019-12-07 08:49:06

问题


I tried to install neurolab, termcolor libraries on Coding Ground for python into the working folder using

pip install --target=. neurolab
pip install --target=. termcolor

and they both worked.
But when I tried:

pip install --target=. numpy

it didn't work.

I'd like to be able to run my scripts that already work on my computer locally on Coding Ground so that I can share my project with people who don't have Python installed on their computer.

UPDATE: I was able to install neurolab, termcolor in the Numpy Terminal after using quit(). But there's no way to share project from Numpy Terminal.

UPDATE: after installing scipy python wheel I tried to run my script and got below error

  File "/home/cg/root/neurolab/train/spo.py", line 73, in __call__                                                                                                       
    from scipy.optimize import fmin_bfgs                                                                                                                                 
  File "/home/cg/root/scipy/optimize/__init__.py", line 233, in <module>                                                                                                 
    from ._minimize import *                                                                                                                                             
  File "/home/cg/root/scipy/optimize/_minimize.py", line 26, in <module>                                                                                                 
    from ._trustregion_dogleg import _minimize_dogleg                                                                                                                    
  File "/home/cg/root/scipy/optimize/_trustregion_dogleg.py", line 5, in <module>                                                                                        
    import scipy.linalg                                                                                                                                                  
  File "/home/cg/root/scipy/linalg/__init__.py", line 174, in <module>                                                                                                   
    from .misc import *                                                                                                                                                  
  File "/home/cg/root/scipy/linalg/misc.py", line 5, in <module>                                                                                                         
    from .blas import get_blas_funcs                                                                                                                                     
  File "/home/cg/root/scipy/linalg/blas.py", line 155, in <module>                                                                                                       
    from scipy.linalg import _fblas                                                                                                                                      
ImportError: libtatlas.so.3: cannot open shared object file: No such file or directory

回答1:


Regarding neurolab and termcolor, they both are pure python modules.

Pure Python i.e. modules are written using only python. These libraries are platform independent and easily distributable.

for numpy, its a python wrapper written over C/C++ library

so, numpy requires a build toolchain, i.e. it needs to be built on platform before using it, this makes numpy module platform dependent.

The coding platforms like "Coding Ground” have a limited build tool chain for building complex C/C++ Python modules/extensions.

one of the solution is to build the module on other machine and then push that on "Coding Ground”.

I have created a build for numpy and uploaded it on my dropbox, you can install it on tutorialspointlike this:

wget "https://www.dropbox.com/s/40l9l9kpc018ehn/numpy-1.11.0-cp27-none-linux_x86_64.whl?dl=0&raw=1" -O numpy-1.11.0-cp27-none-linux_x86_64.whl

pip install --target=. numpy-1.11.0-cp27-none-linux_x86_64.whl

and this will look like

sh-4.3$ pip install --target=. numpy-1.11.0-cp27-none-linux_x86_64.whl                                                      
Processing ./numpy-1.11.0-cp27-none-linux_x86_64.whl  
Installing collected packages: numpy  
Successfully installed numpy  
sh-4.3$   
sh-4.3$ python
Python 2.7.10 (default, Sep  8 2015, 17:20:17)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.    
>>> import numpy     
>>>  

ready to use and share the project.

more reading on how to build a python wheel

Hope this solves your problem.


Edit:

As Tin Tran had requirement for scipy module, have built it for Linux.

you can access it using following script:

wget "https://www.dropbox.com/s/awsvqm4devetljm/scipy-0.17.1-cp27-none-linux_x86_64.whl?dl=0&raw=1" -O scipy-0.17.1-cp27-none-linux_x86_64.whl

pip install --target=. scipy-0.17.1-cp27-none-linux_x86_64.whl

Note: the scipy module has a dependency on numpy, make sure you have numpy installed before hand.



来源:https://stackoverflow.com/questions/37634645/how-would-i-install-numpy-library-on-coding-ground

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!