Run a Python program in Ubuntu
4
0
Entering edit mode
7.9 years ago
Ander ▴ 50

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

Python Ubuntu • 8.8k views
ADD COMMENT
2
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
1
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
4
Entering edit mode
7.9 years ago
Joe 21k

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 COMMENT
2
Entering edit mode
7.9 years ago
GenoMax 147k

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

ADD COMMENT
0
Entering edit mode

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 REPLY
1
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
1
Entering edit mode
7.9 years ago
george.ry ★ 1.2k

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
1
Entering edit mode
7.9 years ago
Ander ▴ 50

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 COMMENT

Login before adding your answer.

Traffic: 1862 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6