-2
$\begingroup$

I am trying to run a script in python but I getting this error

loan-mac-13:vcf2maf fi1d18$ python
Python 2.7.10 (default, Feb 22 2019, 21:55:15) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir("/Users/fi1d18/Downloads/vcf2maf-master/vcf2maf")
>>> 
>>> 
>>> os.getcwd()
'/Users/fi1d18/Downloads/vcf2maf-master/vcf2maf'
>>> vcf2maf.py -h
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'vcf2maf' is not defined
>>> python vcf2maf.py -h
  File "<stdin>", line 1
    python vcf2maf.py -h
                 ^
SyntaxError: invalid syntax
>>> 

Where I am doing wrong?

Thanks for any help

By your comments I run

Sorry says that Last login: Wed Apr 1 11:50:14 on ttys000

pc-133-235:~ fi1d18$ pwd
/Users/fi1d18
pc-133-235:~ fi1d18$ 
pc-133-235:~ fi1d18$ cd Downloads
pc-133-235:Downloads fi1d18$ python vcf2maf.py -h
Traceback (most recent call last):
  File "vcf2maf.py", line 19, in <module>
    import vcf
ImportError: No module named vcf
pc-133-235:Downloads fi1d18$
$\endgroup$
3
  • $\begingroup$ As I said, that's a completely separate issue. Please ask a new question about it. First, however, just copy/paste the error into your favorite search engine. That will give you the answer. $\endgroup$
    – terdon
    Apr 1 '20 at 15:52
  • 1
    $\begingroup$ I am sorry to say, but this is a bioinformatics equivalent of "What is a cell" in biology. It appears to me that you really should go through some python tutorials to get over the basics before you proceed with your research. I heavily recommend software-carpentry.org as a starting point. $\endgroup$
    – Kamil S Jaron
    Apr 4 '20 at 13:22
  • $\begingroup$ You %100 right @KamilSJaron, I am nothing in the first line of python $\endgroup$
    – Exhausted
    Apr 4 '20 at 15:10
4
$\begingroup$

You are trying to run a script file in the python console. That doesn't make sense. The console is for running commands manually, interactively. A script is a collection of commands. You can't just run that by name in the console. If you want to use it, copy the contents of your script and try to run them in the console.

The way you run a python script file is simply:

python vcf2maf.py -h

Or, assuming you have made the file executable and it has the right shebang line, just:

./vcf2maf.py -h

The specific error you are getting is because foo.bar in Python means "run the bar method from the object foo. So vcf2maf.py means run py from vcf2maf. Since there is no object defined with the name vcf2maf, you get the name 'vcf2maf' is not defined.

$\endgroup$
2
  • $\begingroup$ Sorry says that Last login: Wed Apr 1 11:50:14 on ttys000 pc-133-235:~ fi1d18$ pwd /Users/fi1d18 pc-133-235:~ fi1d18$ pc-133-235:~ fi1d18$ cd Downloads pc-133-235:Downloads fi1d18$ python vcf2maf.py -h Traceback (most recent call last): File "vcf2maf.py", line 19, in <module> import vcf ImportError: No module named vcf pc-133-235:Downloads fi1d18$ $\endgroup$
    – Exhausted
    Apr 1 '20 at 12:03
  • $\begingroup$ @Angel I can't read that. Please edit your question to add extra information, don't put it in the comments. And tell me who/what "says" and when. I can't guess what commands you are running. If that's the output of running the script, then it is a completely different issue, you are missing the vcf module. So please ask a new question about that. $\endgroup$
    – terdon
    Apr 1 '20 at 12:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.