I'm trying to use the gfx module for python (from here: http://www.swftools.org/gfx_tutorial.html). But when I do python setup.py build I get an error:
ImportError: cannot import name CompileError
I just need to open a gfx file.. (Its part of the pythonchallenge.com)
How can I do it?
I'm working on linux mint 64bit
enter code here Not sure how stable this is but there seems to be a lot of issues installing 0.9.2 on ubuntu:
wget http://www.swftools.org/swftools-2013-04-09-1007.tar.gz
tar -xzvf swftools-2013-04-09-1007.tar.gz
cd swftools-2013-04-09-1007/
./configure
make
sudo make install
sudo cp lib/python/*.so /usr/lib/python2.7/site-packages/
That should compile and install on ubuntu.
Then python -c 'import gfx' should work.
I had a look at the setup.py script and it seems it is using CompileError from distutils which is now depreciated, I replaced it with from distutils.core import CCompilerError
Running python setup.py runs after changing but complains about various errors in relation to jpeg and PIL._imaging.so so I have included an instuctions.txt in the file which has instructions on how to setup the required packages and symlinks etc...
I also had to add the lib/art directory from swftools on github and add it to the lib directory.
It runs and installs on ubuntu 14.04 but should work on mint also.
The updated package is here
download
http://www.swftools.org/download.html
You can build the Python module using setup.py
You can build it "manually" by using make
To do the former, all that should be required is
python setup.py build
python setup.py install
This is the preferred way. If the above gives you any trouble or you prefer make, the following will also create the Python module:
./configure
make
# substitute the following path with your correct python
installation:
cp lib/python/*.so /usr/lib/python2.4/site-packages/
You can test whether the python module was properly installed by doing
python -c 'import gfx'
Related
I'm on Windows and want to use the Python package apt_pkg in PyCharm.
On Linux I get the package by doing sudo apt-get install python3-apt but how to install apt_pkg on Windows?
There is no such package on PyPI.
There is no way to run apt-get in Windows; the package format and the supporting infrastructure is very explicitly Debian-specific.
Not quite what you're looking for, but it's possible to use apt-offline on Windows to download the packages. However, you still need a Linux box to generate the sig file.
For example:
python apt-offline set vim-offline.sig --install-packages vim
Will not work:
ERROR: This argument is supported only on Unix like systems with apt installed
However, if you run that command on Linux first, the following command should work on Windows:
python apt-offline get vim-offline.sig -d vim
apt-offline source is available here:
https://github.com/rickysarraf/apt-offline
To build it, simply run:
python setup.py build
python setup.py install
I got it to run with Python 3.8.2 on Windows 10.
Note: in the end of the day, you're just downloading a .deb package and it is simply an ar file containing a tarball and can be extracted with tools like 7-zip. However, if it contains a Linux binary (vim example), there isn't much you can do with it on Windows.
One can use chocolatey the equivalent for windows.
https://chocolatey.org/install
add it to the windows PATH environment
C:\ProgramData\chocolatey\bin
Restart python or anaconda. And is ready to use.
To install packages inside a .py script or a Jupiter notebook, use the syntax below
!choco install [package name]
I have created a wrapper for c++ library using python.
I have a bash script that will download c++ code, compile it and copy the generated .so file to the python package.
Then I have written the setup.py so that when you use pip install package-name, it will install the .so file also.
What I need is to run that bash script when I type pip install package-name. Currently what I have to do is run the bash script first and then use pip install package-name to install.
And I need to upload the code to the Python Package Index. So the solution has to be compatible with that also*.
PS: I know about the Extension module in setuptools. I can't use that because I need to download something and run a Makefile after editing it. I do all of that with the bash script.
* I learnt that this requirement is not possible. So please ignore that one.
Thank you..
I am trying to install the development version of owlready2; I take the following step;
Extracted the development version downloaded from https://bitbucket.org/jibalamy/owlready2/downloads/
uninstalled previously installed owlready versions
went to the extracted directory and did python setup.py develop
but it is giving me the error that No module named owlready2
The code I am trying to run is below;
from owlready2 import *
onto = get_ontology("http://myplatform.com/test_sensor_onto")
onto.imported_ontologies = []
sosa = get_ontology("file://sosa.owl").load()
ssn = get_ontology("file://ssn.owl").load()
onto.imported_ontologies.append(sosa)
onto.imported_ontologies.append(ssn)
sensor = sosa.Sensor("mySensor", namespace = onto)
onto.save("test_sensor_onto2.owl")
I have also tried to use python setup.py install, but then it gives an error that
sensor =sosa.Sensor("mySensor", namespace = onto)
TypeError: 'NoneType' object is not callable
This error is same as for non-development versions of owlready2. I am wondering if I am doing anything wrong while installing the development version or I have to change some settings somewhere?
Take a look at your site packages directories with python -c "import site; print(site.getsitepackages())". Make sure a valid link was created in one of those directories for your package.
You might also try using pip -e (editable installs) as an alternative. This is similar to setuptools develop mode. sudo pip install -e /my/package/path. Using pip will install any dependencies required by the package.
setup.py may also require sudo to update the site-wide package directory. Add -v for verbose output: sudo python setup.py -v develop
I try to create a debian package of a python application as follows:
Write a setup.py
Generate a debian folder by stddeb
Run dpkg-buildpackage -b -rfakeroot -uc to build the debian package
The setup.py is like
#!/usr/bin/env python
from distutils.core import setup
setup(name='foo',
version='1.0.0',
description='Foo example',
author='Kuan-Kai Chiu',
author_email='ntu.kchiu#gmail.com',
scripts=['src/foo.py']
)
How do I install the foo.py to /usr/local/bin instead of being installed to /usr/bin? I know there's an option --install-scripts=/usr/local/bin while running python setup.py install, but I have to debianize my python application and it seems no way to specify the install-scripts prefix.
Thanks in advance!
If you just want to install a file in /usr/local/bin/, then drop the setup.py as it's not really needed. If you are using dh in your package (you can see if you are by checking it's being invoked in your debian/rules file. If you aren't using it, you should :-), then you'll only have to feed dh_install (see its manpage) with an install file. The syntax of this file is really simple, you have to specify what do you want to install, and where. You can do this by issuing the following command in the root directory of your package:
$ echo "src/foo.py usr/local/bin" > debian/install
Now, as you want to install a script under /usr/local/, and this is against the Debian policy, one of the dh_* tools will fail. This tool is dh_usrlocal. The fix is quite simple. We just have to tell debian/rules that we don't want to run it, and we can do this by overriding its behavior. This is how your final debian/rules should look:
#!/usr/bin/make -f
# -*- makefile -*-
%:
dh $#
override_dh_usrlocal:
That's it. Run dpkg-buildpackage and you should have your fresh new packages in ../.
I would like to use pysqlite interface between Python and sdlite database. I have already Python and SQLite on my computer. But I have troubles with installation of pysqlite. During the installation I get the following error message:
error: command 'gcc' failed with exit status 1
As far as I understood the problems appears because version of my Python is 2.4.3 and SQLite is integrated in Python since 2.5. However, I also found out that it IS possible to build sqlite for Python 2.4 (using some tricks, probably).
Does anybody know how to build sqlite for Python 2.4?
As another option I could try to install higher version of Python. However I do not have root privileges. Does anybody know what will be the easiest way to solve the problem (build SQLite fro Python 2.4, or install newer version of Python)? I have to mention that I would not like to overwrite the old version version of Python.
Thank you in advance.
You can download and install Python to your home directory.
$ cd
$ mkdir opt
$ mkdir downloads
$ cd downloads
$ wget http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tgz
$ tar xvzf Python-2.6.2.tgz
$ cd Python-2.6.2
$ ./configure --prefix=$HOME/opt/ --enable-unicode=ucs4
$ make
$ make install
Then, (if you are using bash) in your .bash_profile do
export PATH=$HOME/opt/bin/:$PATH
export PYTHONPATH=$HOME/opt/lib:$HOME/opt/lib/site-packages:$PYTHONPATH
Then, source the file to make it available
$ cd
$ source .bash_profile
$ python -V
where python -V will return the python version. If the correct version appears, any packages that you run with Python's setup.py util (assuming the developer followed the correct conventions) will install in ~/opt/lib/python2.x/site-packages directory.
Download pysqlite here, cd into the directory you downloaded to, unpack the tarball:
$ tar xzf pysqlite-2.5.5.tar.gz
then just do (if your permissions are set right for this; may need sudo otherwise):
$ cd pysqlite-2.5.5
$ python2.4 setup.py install
one error does appear in the copious output:
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/pysqlite2/test/py25tests.py", line 48
with self.con:
^
SyntaxError: invalid syntax
since as clearly shown that file is for py 2.5 tests only (with statement not present in 2.4!-). Nevertheless the install is successful:
$ python2.4 -c'import pysqlite2'
$
All this is on Mac OS X 10.5 but using python2.4 separately installed from the system-supplied Python 2.5.
The error you report doesn't tell us much -- maybe you're missing the headers or libraries for sqlite itself? Can you show us other output lines around that single error msg...?
If you don't have root privileges, I would recommend installing a more recent version of Python in your home directory and then adding your local version to your PATH. It seems easier to go that direction than to try to make sqlite work with an old version of Python.
You will also be doing yourself a favor by using a recent version of Python, because you'll have access to the numerous recent improvements in the language.
I had the same trouble with gcc failing with Ubuntu Karmic. I fixed this by installing the python-dev package. In my case, I'm working with python2.4, so I installed the python2.4-dev package. The python-dev package should work for python2.6.