Question: Run a Python program in Ubuntu
0
gravatar for Ander
2.6 years ago by
Ander50
Spain
Ander50 wrote:

Hi there,

I'm posting this as I' am very frustated with this after some hours of not getting results. I'm running Ubuntu 14.0-64 bit in a virtual machine. I installed two Python packages (https://github.com/fls-bioinformatics-core/GFFUtils and https://github.com/fls-bioinformatics-core/genomics) by downloading the zips from Github, extracting them and running sudo python setup.py install in their directories. The first one needed to be installed before because of some dependencies but no problem after installation, everything rigth. I have python 2.7.6 and 3.4.0 installed.

Now, how do I run those programs? How does this work? I've been searching Google for hours and haven't found a way to run this thing. I'm desperate...

Thanks in advance for your help Ander

ubuntu python • 5.1k views
ADD COMMENTlink modified 2.6 years ago • written 2.6 years ago by Ander50
2

first how did you tried to run them? in general to run python script you issue command like python your_script.py

and to know which python running the command you should run which python

ADD REPLYlink written 2.6 years ago by Medhat8.4k

I tried to run them as you advise: after running sudo python setup.py install I cd to the desktop directory where the *.py files are located and try python GTF_extractt.py but i get

Traceback (most recetn call last): File "GTF_extract.py", line 21, in <module> from . import get_version ValueError: Attempted relative import in non-package

What does this mean? What am I doing wrong?

ADD REPLYlink written 2.6 years ago by Ander50
1

can you please do this sed -n '20,22p' GTF_extractt.py and write down the result

ADD REPLYlink modified 2.6 years ago • written 2.6 years ago by Medhat8.4k
1

Ander : Did you also test the GFFUtils install by doing python setup.py test as suggested?

ADD REPLYlink modified 2.6 years ago • written 2.6 years ago by genomax70k
1

from the documentation line 21 is
from . import get_version __version__ = get_version()

you have the error because

Means you attempt to use relative import in the module which is not package http://stackoverflow.com/a/4351737/1798298

you are missing some packages I think your installation is not correct

please refer to what @genomax2 said and use the test module

ADD REPLYlink modified 2.6 years ago • written 2.6 years ago by Medhat8.4k

I run the test module and it said everything was OK. Do you suggest my python installation is not correct or that of GFFUtils?

I don't have access to the computer right now, I'll try and run the "sed -n" command this afternoon.

Again, thanks a lot for your support, I have zero idea about python and this has become really frustrating.

ADD REPLYlink written 2.6 years ago by Ander0
4
gravatar for jrj.healey
2.6 years ago by
jrj.healey13k
United Kingdom
jrj.healey13k wrote:

My preferred way to install modules so that there is no confusion between python versions and pip versions is:

$ python -m pip install packagename

So:

python -m pip install -r https://raw.githubusercontent.com/fls-bioinformatics-core/GFFUtils/master/requirements.txt

Should work I think...

Normally it'll figure out dependencies itself - as that's what the requirements.txt is for.

Then in your script or python interpreter:

import packagename

ADD COMMENTlink written 2.6 years ago by jrj.healey13k
2
gravatar for genomax
2.6 years ago by
genomax70k
United States
genomax70k wrote:

Documentation (usage and options for the programs) are available for GFFUtils and genomics-bcftbx. What exactly are you trying to do?

ADD COMMENTlink written 2.6 years ago by genomax70k

I'm trying to run a GFFUtils feature in a GFF file, but I can't find the way, usage and options only specify "GTF_extract.py OPTIONS <gft_file>". I want to run that GTF_extract.py.

ADD REPLYlink written 2.6 years ago by Ander50
1

Sounds like you could use a basic primer on unix and how to run programs.

If you want to run GTF_extract.py (which is a python script) then you provide any options you need where the OPTIONS part is there followed by the name of the gtf file you are using. e.g. GTF_extract.py -f exon my_genome.gtf -o extracted_info.file.

ADD REPLYlink modified 2.6 years ago • written 2.6 years ago by genomax70k

That's what I have been trying to do, but i get this promt when running GTF_extract.py -f strand my_genome.gtf -o extracted_info.file:

Traceback (most recetn call last): File "GTF_extract.py", line 21, in <module> from . import get_version ValueError: Attempted relative import in non-package

ADD REPLYlink written 2.6 years ago by Ander50
1
gravatar for george.ry
2.6 years ago by
george.ry1.1k
United Kingdom
george.ry1.1k wrote:

This isn't your problem I don't think ... the package isn't handling it's own imports properly. You probably just need to change from . import get_version to from GFFUtils import get_version.

The program isn't doing anything particularly exciting anyway, though, so you could also just do it in a different way in any case.

ADD COMMENTlink written 2.6 years ago by george.ry1.1k

Hey friend. I'm an international applicant who want to apply for M.S of Computational Biology of CMU. Could you help me to have a glance at one paragraph, which I write newly, of my SOP? I'm afraid I don't express things naturally. It is a little urgent since the deadline is in 8 hours. Thanks!

ADD REPLYlink written 2.4 years ago by syndoom10

This thread is old, and this is not the place for additional questions. You should ask your question as a full thread on the main page of the site - though it's not strictly bioinformatics so don't be surprised if it gets closed.

ADD REPLYlink written 2.4 years ago by jrj.healey13k

Yes, it would indeed get closed. In addition, I removed all other off-topic reactions syndoom1 made with the same text in unrelated threads. It looks like you genuinely need help, but this looks a remarkable lot like spam so if this continues your account will be suspended.

ADD REPLYlink modified 2.4 years ago • written 2.4 years ago by WouterDeCoster40k
1
gravatar for Ander
2.6 years ago by
Ander50
Spain
Ander50 wrote:

Well, I don't know how I did it but the program now runs perfectly from Ubuntu Terminal without specifying any extra route, it does everything that I've dreamed of. Think it was something realted to what @jrj.healey suggested.

Thanks again all of you for your kind support!!!

ADD COMMENTlink written 2.6 years ago by Ander50
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1172 users visited in the last hour