How come when I move a python file into scipy.stats folder in ubuntu it disappears? -


i downloaded http://projects.scipy.org/scipy/attachment/ticket/846/mvncdf.py

i: sudo mv ~/downloads/mvncdf.py /usr/lib/pyshared/python2.7/scipy/stats

and disappears

i tried saving directly /usr/lib/pyshared/python2.7/scipy/stats , still disappears.

overall i'm not sure how move can call python program if have imported scipy.stats, scipy.stats.kde, etc. i'm trying solve.

there few ways import external libraries in python. simplest launch program or interpreter same directory file, so

$ mkdir new_program $ mv ~/downloads/mvncdf.py new_program/. $ cd new_program $ python >>> import mvncdf 

alternatively, suggested @tcaswell, can add local path pythonpath environment variable,

$ mkdir ~/python_scripts  $ mv ~/downloads/mvncdf.py python_scripts/. $ pythonpath=$pythonpath:$home/python_scripts $ export pythonpath 

the last 2 lines can placed in ~/.bashrc or ~/.bash_profile variable set every time log in.

a more permanent way find directory in sys.path such local user "installed" programs should go. convention, in 1 of site-packages directories distribution. if using python version 2.7, be:

$ sudo mv ~/downloads/mvncdf.py /usr/lib/python2.7/site-packages/. 

you can check directories in sys.path python shell

>>> import sys >>> in sys.path: ...     print ... 

however, placing own files in /usr/lib/python2.7/site-packages/ discouraged may over-written during python update. proper way, , way adheres closest fhs, create site-packages directory under /usr/local, e.g.,

$ sudo mkdir -p /usr/local/lib/python2.7/site-packages 

then edit /usr/lib64/python2.7/site.py, find prefixes variable, , add new directory list, e.g.,

prefixes = [sys.prefix, sys.exec_prefix, '/usr/local'] 

ubuntu may have directory in sys.path, check before creating , editing site.py. of course, if have modify site.py, run in same issues when upgrading python placing file in directory under /usr/lib.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -