Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python newbie - PIP / invalid syntax error [duplicate]

Ok, totally newbie to programming and python. Running Windows 7, python 2.7 x64. I am trying in install dateutil package using pip.

I installed pip, numpy and pandas... which were pretty straightforward as they are exe files.

I am now trying to use pip to install dateutil. In the Python Shell, I have typed:

pip install dateutil 

and

pip install python-dateutil

I continue to get "Invalid Syntax" errors at the install command. What am I doing wrong here? I have also tried this in the python command line.

I have checked my modules installed and I have both pip and easy_install. Really confused right now...I also have tried running the setup script for dateutil and I get this error:

Traceback (most recent call last):
  File "C:\Python27\Scripts\python-dateutil-1.5.tar\python-dateutil-1.5\setup.py", line 14, in <module>
    TOPDIR = os.path.dirname(__file__) or "."
NameError: name '__file__' is not defined

Help please! Thanks in advance for any help.

like image 379
user2338676 Avatar asked May 01 '13 07:05

user2338676


People also ask

How do I fix pip invalid syntax?

If you get a "SyntaxError: invalid syntax" when trying to install a module using pip , make sure to run the command from your shell, e.g. bash or PowerShell, and not by running a Python file that contains the pip install your_module command.

Why is pip install invalid syntax?

The python pip invalid syntax error is occurring because pip is run from the command line, not the Python interpreter. It is a program that installs modules, so you can use them from Python. Once you have installed the module, then you can open the Python shell and do import selenium.


1 Answers

You don't type that in the Python shell. You type it in the command prompt (haven't used Windows for years, but it used to be called cmd).

like image 126
Daniel Roseman Avatar answered Oct 07 '22 06:10

Daniel Roseman