Tag Info

New answers tagged

1

setup.py is the file that will handle the installation of your packages. you execute it by prefixing it with the python command and by passing install as a parameter, hence, the "python setup.py install". .pyc are the compiled bytecode of your python code (for faster execution). So if yoou are moving your code, I suggest you take the .py files and remove the ...


1

User hhlp answer already says that the system folders are: /usr/lib/nautilus/extensions-2.0/python /usr/lib/nautilus/extensions-3.0/python According to this answer, you should also have a look in these directories in your home directory: ~/.local/share/nautilus-python/extensions/ ~/.local/share/nautilus/scripts Still found them on my v14.10.


0

Why don't just do python /home/user/breve_2.7.2/demos/Getting-Started/RandomWalker_version.py in the last line. That should solve it (when the shebang is correct).


0

Since you have multiple python versions installed and you want to determine which python is to be used as default, you should use update-alternatives command which maintains symbolic links determining default commands. First of all run this: update-alternatives --list python If the result is: update-alternatives: error: no alternatives for python Then ...


1

GtkFileChooserButton in Folder Select mode can return the folder URI. Use urlparse module to convert URI to path. This works even with bookmarks. Hope this solves your issue. import urlparse folder_uri = filechooserbutton_meas.get_uri() folder = urlparse.urlparse(folder_uri).path


0

Where should it be? By default when you open the file manager you run around your home directory(/home/username), same as in windows C:\Users\Username . Notice how /usr/local starts with backslash ? There's root directory from which you can access other directories; the image to keep in mind is the root directory is where root starts, and everything else is ...


0

you don't have to save the graphics.py in /usr/lib/python3/dist-packages, it is easier if you do make a folder for your project myproject and save the graphics.py in that folder and then make another python module <name it>.py and inside it do import graphics or from graphics import <method name> or you can put your graphics.py file inside ...


0

What you are looking for are virtual environments. They allow you to have different version of a package. They also make it possible to have several versions of python live together. Make a virtual environment that uses 2.4. Install numpy in it. Run your script in that venv (virtual environment). Enjoy.


0

Clone the respoitory with: git clone http://github.com/kivy/kivy cd kivy It could be that you still need some packages. sudo apt-get install cython sudo apt-get install libgstreamer1.0-dev sudo apt-get install libsdl2-dev sudo apt-get install libsdl2-ttf-dev sudo apt-get install libsdl2-image-dev sudo apt-get install libsdl2-mixer-dev For a standard ...


1

This installation is failing because lack of permissions. creating /usr/local/lib/python2.7/dist-packages/buster error: could not create '/usr/local/lib/python2.7/dist-packages/buster': Permission denied Did you install it with sudo?: sudo pip install buster


0

I have successfully installed django-mathfilters 0.3.0 using the command: pip install django-mathfilters Then add mathfilters to your INSTALLED_APPS. This is the same command that is found at the Python Package Index django-mathfilters webpage. It was a local install, so I didn't need to use sudo. I also already had the latest version of django ...


5

There are actually a number of packages that allow you to write a command line interface. I know that click has a progress bar, for instance. Oh, and regarding your requirement "pure python", that my friend is something that is unpythonic. Python wants you to use third party packages.


10

Though a proper library is the best solution, I'd like to show a simple alternative: use \r (carriage return) instead of \n (line feed) for line endings, so that that the cursor is placed at the start of the current line, instead of on the next line. #! /usr/bin/python3 from time import sleep for i in range(100): print('[' + '='*i + ' '*(100-i) + ']', ...


6

Solution hinted by Helio works great! I needed to pip install progressbar first but then one of official examples works like a charm. from progressbar import * pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=300).start() for i in range(300): time.sleep(0.01) pbar.update(i+1) pbar.finish() Official site (with examples): ...


1

I installed PyCharm in ~/bin directory. I created this directory manually. So the IDE files were in a directory like ~/bin/pycharm-community-3.x.x. To update it I did the following, Deleted the folder ~/bin/pycharm-community-3.x.x Deleted the folder ~/.PyCharm30 (directory used by PyCharm for storing settings, caches etc.) Downloaded the latest version of ...


1

In my case LMSensor was missing. Running sudo apt-get install lm-sensorsthensudo pip install pysensors worked for me.


1

Follow these steps; wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add - sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu trusty-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list' sudo apt-get update sudo apt-get install pycharm Then sudo apt-get purge openjdk* sudo add-apt-repository ppa:webupd8team/java sudo ...


0

I believe the best practice is to install all tar balls in /usr/local/src. Also, you don’t have to move the tar ball, you can specify where to unzip to using the -C (change extraction destination?) specifier so it becomes (this assumes the old version is located in /usr/local/src as it should be): sudo tar xzf pycharm-community-4.0.4.tar.gz -C ...


-1

Scypy is the collection of python packages for Data Analysis, there is no way you are going to import it like that in Python Shell. Here is a [link] ( http://www.scipy.org/install.html), how to install the packages on your Ubuntu. You can stary by downloading and reading this book


3

If you're looking for a system command that always returns a non-zero exit code, then /bin/false seems like it should work for you. From man false: NAME false - do nothing, unsuccessfully SYNOPSIS false [ignored command line arguments] false OPTION DESCRIPTION Exit with a status code indicating failure.


2

You can create a new return code with the command bash -c "exit RETURNCODE", replacing "RETURNCODE" with any number. Note that it will be trimmed to an 8bit unsigned integer (0...255) by (RETURNCODE mod 256) You can check the return code of the last shell command inside the terminal(!) with executing echo $?. The "$?" variable contains the most recent ...


0

After some more testing, I found that my problem was not on the "Linux" side. Python has a module shlex; which should be used to "split" command strings. When I changed my subprocess call to use the output of shlex.split() invoking "bash exit 1" gives me what I need.


-2

Open terminal and write the following: sudo apt-get autoremove If you don't want to do things by hand do the following: sudo apt-get install bleachbit sudo bleachbit and clean your system. If nothing works install python and uninstall it again :)


0

You need the Python 3 versions of the packages. sudo apt-get install python3-gi


0

The first CLAHE implementation was committed in 5810a73 CPU implementation of CLAHE, which made its first release appearance in version 2.4.5. Therefore you need to update your version of OpenCV to ≥ 2.4.5.


1

You are trying to install a Python 3 module in Python virtual environment (python-virtualenv) which is specific to Python 2.x. In order to use pip3 to install Python 3 modules in Ubuntu 14.04, you must create a Python virtual environment for Python 3.x by following the instructions in this answer. Then you can install the Selenium module in the new Pyvenv ...


2

Python cannot perform a shell's job and do command substitution. You would have to perform the command substitution yourself, or wrap the whole thing using sh -c or bash -c: For example, using subprocess.check_output() to get the output of the pkgconfig command: import subprocess pkg_config_flags = subprocess.check_output(['pkg-config', '--cflags', ...


0

Bleh can't comment still yet, Above is correct, but if you use pgrep you have less to cleanup. It only returns the pid's (and not the entire line of ps). p = subprocess.Popen("sudo kill -9 $(sudo ps aux| pgrep '(" + mac_host + ")')", shell=True, stdout=subprocess.PIPE) Edit: If you want to try without using subprocess/shell commands, you could try ...


0

I guess this should be a regular expression? grep '(" + mac_host + ")' Try with egrep or grep -e. Looks like you want to use regular expressions but are looking for exactly the term you enter above. Or if it is called mac_host alle the time, then get rid of everything else grep "mac_host" Also put a set +x in your script to debug your script. ...


1

Since Raring (13.04), perf is built without Python scripting enabled “to avoid a Python build dependency”. This came as a nasty shock to people like me who used perf in 12.04 LTS and upgraded to 14.04 LTS. This is documented in the debian-master/changelog file in the Ubuntu kernel git repos. In short, if your kernel is 3.8.0-6.11 or later, you are — to use ...


0

I solved it. Maybe it would be useful for someone. I delete manually with sudo rm -R /usr/local/lib/python2.7 folder with python dist which causes error. Then I reinstall python, scrapy and django manually from a source.


0

You need to use apt.cache and apt.package. Adapting the example given for apt.package: !# /usr/bin/env python2 import apt cache = apt.Cache() Games = [pkg for pkg in cache if pkg.section.endswith("/games")] print("\n".join(map(lambda x: x.name, Games[1:10]))) cache is like a dictionary object, with package names (+ an optional architecture label) as the ...


0

You don't actually need a regex for this. string.startswith and string.endswith function will do this job. $ python3 -c 'import sys with open(sys.argv[1]) as f: for line in f: if line.startswith("l") and line.strip().endswith("op"): print(line, end="")' file leptop leptop laftop laptop


0

Looks like you downloaded it and are trying to compile from source. Here's a link to a stackoverflow question I think might work for you - someone with the same issue. Essentially you need to install openssl before compiling python from source. http://stackoverflow.com/questions/22592686/compiling-python-3-4-is-not-copying-pip


1

Setting an alias is essentially a user shortcut and does not affect your environment outside of your terminal(see description of 'alias' here). Your question doesn't explain what the 'end goal' is, so I'll answer the two I can think of. If you only interested in a shortcut:Don't do it! Just use 'python3.4' - it's 3 more keystrokes... If you want to use ...


0

Python code can be compiled and run from Sublime using Ctrl+B or Tools->Build System->Python. I'm just not sure why the script in your Dropbox folder won't run, have you checked the file permissions?


1

There is no python3-virtualenv package in the Ubuntu repositories. There is a python-virtualenv package in the Ubuntu repositories, but that package won't work for installing Python 3.x modules in a Python virtual environment. python-virtualenv only works for installing Python 2.x modules in a Python virtual environment. The way to install Python 3.x ...


0

Please install first these packages: libgee-0.8-2 libgee-0.8-dev You can install them with this command: sudo apt-get install libgee-0.8-2 libgee-0.8-dev Or with this other: sudo apt-get install libgee-0.8*


1

The pkg-config --modversion opencv command only tells you your system has the development libraries and headers for OpenCV: the python bindings are in a separate package called python-opencv. You can install that from the Software Center, or from a terminal using sudo apt-get install python-opencv


0

Here you're a bash solution: #!/bin/bash if [ ! -f "$1" ]; then echo "File not found!" exit fi names=$(cat "$1" | sort) for i in $names; do filename=${i%.*} extension=${i##*.} number=${filename: -2:2} name=${filename//[0-9]} fnumber=$(printf "%02d\n" $((${number#0}+1))) if [[ "$name" == "test" ]]; then echo ...


2

You can use the following perl oneliner to do the transformation: echo "test00.dat test09.dat aram22.dat" | perl -pe 's/test\K(\d+)/sprintf "%02d", $1+1/eg' Result: test01.dat test10.dat aram22.dat To use your input file: $ perl -pe 's/test\K(\d+)/sprintf "%02d", $1+1/eg' your_file test01.dat test08.dat test04.dat aram22.dat test10.dat aram09.dat ...


0

The script below assumes the numbers in the words occur consecutively in the filenames (e.g. file_123.dat, not file12something345.dat), and the names of the files are unique. What it does It searches the file for words with integers in the name. It will convert those (consecutive) integers int "real" integers (values), which will remove the leading zeros. ...


0

A quick'n'dirty solution based on How to find and replace a particular string by increasing its numerical part? (suggested by KasiyA) echo "test00.dat test07.dat aram22.dat" | perl -pe 's/(?<=test)(\d+)/$1+1/eg' | sed -e 's/test\([0-9]\)\./test0\1/g' test01dat test08dat aram22.dat Note that there is an ugly hack in my command: perl outputs test1.dat ...


1

_chipset is supposed to be a native module (see chipset.i in the same directory), that you need to build from source apparently. Rough download and compilation instructions: Install git with the package manager and clone the repository: git clone git://anongit.freedesktop.org/xorg/app/intel-gpu-tools cd intel-gpu-tools Install build tools ...


1

To use Tkinter, all you need to do is to import one module: import Tkinter Or, more often: from Tkinter import * So just change your import line to import Tkinter for example: $ python Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ...


0

I'm not sure precisely the issue here but it is likely that you will need to setup a user as per Thinclient guide and then use the console connect command: deluge-console "connect 127.0.0.1:58846 user pass; add -p ..."


1

You really should ask only one question per question but: 1) Python is a really good choice for building GUI apps 2) You use some kind of toolkit to build GUI applications, if you want to develop apps that work in both Windows and Linux, QT is the best option to me. To use python and qt you can use pyqt. You will find some tutorials in the pyqt page 3) ...


0

Version 2.0 has many bugs open. I had success with version 2.1.1.


1

I have found out what was wrong, /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so was using the shared library /usr/local/lib/libexpat.so.1 when it should have been using /lib/x86_64-linux-gnu/libexpat.so.1 and simply renaming or removing /usr/local/lib/libexpat.so.1 solved the issues with python. A source can be found here


0

I had trouble getting any of the other examples to actually work but I got there in the end. Here's a working example: import glib import dbus from dbus.mainloop.glib import DBusGMainLoop def print_notification(bus, message): keys = ["app_name", "replaces_id", "app_icon", "summary", "body", "actions", "hints", "expire_timeout"] args = ...



Top 50 recent answers are included