Hot answers tagged

3

If you want to install Python packages from source, you should do so in a virtualenv. That way you minimize the chance that you break your system's python, and it you make it possible to just remove the installed package without fear of removing too much. In order to do so you must first install virtualenv, e.g. using sudo apt-get install ...


3

For python at least I recomend "Learn Python The Hard way", by Zed Shaw. Freely available online. Good stuff. Not sure if posting a link here is technically advertising... Here goes. Free Book


3

To make something like this easily executable, add this as the first line of the python script: #! /usr/bin/python and the file itself should be executable; that is, the x bits must be set, chmod +x fit_locus.py. Since the script is in the amended PATH, users can just enter the name. For simplicity, you can remove the '.py' so users only need to type ...


2

There are many. I can suggest two for python: codecademy: to learn syntax and get a basic understanding of the langauge newcoder.io: some projects to go further


2

You can do this with awk, keeping track of numeric versus non-numeric columns and summarizing at the end: #!/usr/bin/awk -f BEGIN { width = 0; } { if (width < NF) width = NF; for (n = 1; n <= NF; ++n) { if ( $n ~ /^[0-9]+$/ ) { number[n] += $n; total[n] += 1; } else { others[n] ...


2

CentOS 7.x is derived from Red Hat Enterprise 7.x, which is designed to be stable. That inevitably means that the programs which are available from the repositories have been tested for a while. You can see that from the description on their website: The CentOS Project is a community-driven free software effort focused on delivering a robust open ...


1

Take a look at this question. It talks about having pip install in a different directory. This would allow you to maintain the rpm installs and have the latest version. I would probably uninstall the rpm version if you don't plan to use it. https://stackoverflow.com/questions/2915471/install-a-python-package-into-a-different-directory-using-pip


1

You should first simplify your alias, there is no need to do the activate stuff. What is important is the first, shebang, line of the python script. It should read: #!/path/to/your/virtualenv/bin/python If the script is executable ( chmod +x script_name ) then the above line make sure that the python installed in virtualenv is called, and that ensures ...


1

Unfortunately for Python 2.6, compiling from source doesn't work properly on Debian 8 (Jessie) but I found, at least for a Raspberry Pi, that I was able to use older packages from http://packages.debian.org. The order, assuming build-essentials are already in place is something like libdb, python2.6-minimal, python2.6, libpython2.6, python2-6-dev but dpkg -i ...


1

You can test this without the rest of pymouse by firing up python and running from Xlib.display import Display display = Display() display.record_create_context which should print <bound method Display.create_context of <Xlib.display.Display instance at ...>> Looks like that corresponds to $ xdpyinfo | grep -i record RECORD (that's ...


1

You should install the package python-dev.


1

It seems that the C compiler (probably gcc) cannot find Python.h. You can either edit the source of SPI-Py to point to PyPy's version, or you can install the appropriate python-dev package to perform the SPI-Py install. Install python-dev This is the least intrusive method, but it may be considered "bulky" since you already have PyPy on the system. If ...


1

Don't reinvent your own password store. Use an existing one. The Linux world has mostly converged on GNOME Keyring. Seahorse provides a convenient GUI for exploring and modifying the keyring and setting a master password. The keyring can be queried from the command line with the secret-tool utility. secret-tool store --label='Foobar webservice' service ...


1

The following should work with python 2 and 3, save as xyz.py and run with python xyz.py file_1 file_2 file_3: import sys import csv names = set() files = {} for file_name in sys.argv[1:]: b = files.setdefault(file_name, {}) with open(file_name) as fp: for line in fp: x = line.strip().split() names.add(x[1]) ...


1

You can call your python script as any name as you like, say search_replace.py #!/usr/bin/env python3 import fileinput import re for line in fileinput.input(inplace=1, backup='.bak'): line = re.sub('farah/StudioInstallation','rose/validation', line.rstrip()) print(line) run this script and pass your filename that is xxx.sh as an ...


1

It's possible if you use two non-portable things: GNU awk's two-way I/O (see relevant StackOverflow answer); millisecond output with date (see this ServerFault answer). With that, you can prefix the input with timestamps like that: awk '{"date +%Y%m%d%H%M%S%3N" |& getline timestamp; print timestamp,$0; close("date +%Y%m%d%H%M%S%3N")}' ...



Only top voted, non community-wiki answers of a minimum length are eligible