<p>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 <em>contents</em> of your script and try to run them in the console. </p>

<p>The way you run a python <em>script file</em> is simply:</p>

<pre><code>python vcf2maf.py -h
</code></pre>

<p>Or, assuming you have made the file executable and it has the right <a href="https://en.wikipedia.org/wiki/Shebang_(Unix)" rel="nofollow noreferrer">shebang line</a>, just:</p>

<pre><code>./vcf2maf.py -h
</code></pre>

<hr>

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

CC BY-SA 4.0
2020-04-01T12:03:47.543Z
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$
Zizogolu
CC BY-SA 4.0
2020-04-01T12:26:35.417Z
@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.
terdon
CC BY-SA 4.0
2020-04-01T11:53:52.413Z
2020-04-01T11:53:52.413Z
terdon
<p>I am trying to run a script in python but I getting this error</p>

<pre><code>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.
&gt;&gt;&gt; import os
&gt;&gt;&gt; os.chdir("/Users/fi1d18/Downloads/vcf2maf-master/vcf2maf")
&gt;&gt;&gt; 
&gt;&gt;&gt; 
&gt;&gt;&gt; os.getcwd()
'/Users/fi1d18/Downloads/vcf2maf-master/vcf2maf'
&gt;&gt;&gt; vcf2maf.py -h
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
NameError: name 'vcf2maf' is not defined
&gt;&gt;&gt; python vcf2maf.py -h
  File "&lt;stdin&gt;", line 1
    python vcf2maf.py -h
                 ^
SyntaxError: invalid syntax
&gt;&gt;&gt; 
</code></pre>

<p>Where I am doing wrong?</p>

<p>Thanks for any help</p>

<p>By your comments I run</p>

<p>Sorry says that Last login: Wed Apr  1 11:50:14 on ttys000</p>

<pre><code>pc-133-235:~ fi1d18<span class="math-container">$ pwd
/Users/fi1d18
pc-133-235:~ fi1d18$</span> 
pc-133-235:~ fi1d18<span class="math-container">$ cd Downloads
pc-133-235:Downloads fi1d18$</span> python vcf2maf.py -h
Traceback (most recent call last):
  File "vcf2maf.py", line 19, in &lt;module&gt;
    import vcf
ImportError: No module named vcf
pc-133-235:Downloads fi1d18$
</code></pre>

CC BY-SA 4.0
2020-04-01T15:52:29.190Z
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.
terdon
CC BY-SA 4.0
2020-04-04T13:22:47.140Z
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 https://software-carpentry.org/ as a starting point.
Kamil S Jaron
CC BY-SA 4.0
2020-04-04T15:10:11.237Z
You %100 right @KamilSJaron, I am nothing in the first line of python
Zizogolu
<python><vcf><software-usage>
Running a script in python
# Running a script in python

(Asked by: username_0 on 2020-04-01)

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 "", line 1, in 
NameError: name 'vcf2maf' is not defined
>>> python vcf2maf.py -h
  File "", 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 
    import vcf
ImportError: No module named vcf
pc-133-235:Downloads fi1d18$

**Tags:** python, vcf, software-usage
> **Comments:**
> **username_1**: 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.  
> **username_2**: 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 https://software-carpentry.org/ as a starting point.  
> **username_0**: You %100 right @KamilSJaron, I am nothing in the first line of python  

---

## 1 answers

### Answer by username_1 on 2020-04-01. Score: 4 | Accepted answer

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.

> **Comments:**
> **username_0**: 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$  
> **username_1**: @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.  

---

