Thanks for reading this. I need some very basic help in Python (2.7.6) I am basically a novice programming (aside from writing programs to display "hi mom" in the late 80s in BASIC, I know nothing). I am trying to run some python scripts that someone has already written.

However, I'm so clueless (hey, at least I admit to my ignorance) I don't really know how to do this.

I've installed Python on my Win7 computer. I can run the shell and the fancier IDLE GUI shell.

The script I am trying to run requires a module called BeautifulSoup.

I have tried installing this in several ways, but it doesn't seem to be working. When my script tries to call it up, it says it can't find it: "ImportError: No module named BeautifulSoup"

The main thing I don't understand is sort of "where I am" when I am in the python shell. In other words, what folder am I in and what folder to I need to put the BeautifulSoup files into. (Right now, it's a folder in my c:\Python27 directory.)

The BeautifulSoup page mentions installing it using PIP, so I downloaded that and ran the install. This seemed to work, the shell told me it restarted, but when I tried to run "pip install BeautifulSoup" it highlighted "install" and gave an invalid syntax error.

So basically, I am lost and I am lost enough that I don't even know the right question to ask. Feel free to make fun of me for this , but any help would also be greatly appreciated.

I've got my music in an xml file and am trying to run the 'xml2h.py' script.

Again, I am not sure where to properly place the files that go with that script and the script itself. (Though I do seem to be able to run it.) I think one thing that would help me orient myself would just be the knowledge of where to put it so I could "run" the script from the main shell command line, or how to move around between directories in the shell.

Thank you so much for any help, and I'll be glad to answer any questions, since I may have forgotten to put in some pretty important information.

beginnersluke wrote:The BeautifulSoup page mentions installing it using PIP, so I downloaded that and ran the install. This seemed to work, the shell told me it restarted, but when I tried to run "pip install BeautifulSoup" it highlighted "install" and gave an invalid syntax error.

That command is supposed to be run in a Windows command prompt/shell, not the Python shell. The windows shell is something like

Both of those accept different things, the first one no Python code and the second one only Python code. If you put your command into the first one it very well may solve your problem (or at least allow you to move forward).

beginnersluke wrote:The main thing I don't understand is sort of "where I am" when I am in the python shell. In other words, what folder am I in and what folder to I need to put the BeautifulSoup files into. (Right now, it's a folder in my c:\Python27 directory.)

in that session already. Do note however that if you've install a module such as BeautifulSoup it shouldn't matter where you are. In general though if you care about where the shell is in your file system, if you're using Python through a Windows command prompt then the current working directory for Python is the directory you launched it in, and IIRC IDLE starts in your home directory.

I hope I've helped a bit, if you still have questions or if anything I said was unclear feel free to post any followup questions.

Join the #python-forum IRC channel on irc.freenode.net for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from

Thank you micseydel. Based on some of your hints, I think I've made some progress and I definitely just have a better grasp as to what is going on when I'm typing. I have a long way to go, but I fell as I've learned something, so thanks again.

I think I've gotten the BeautifulSoup module loaded manually. That is, when I type "import BeautifulSoup" I don't get any errors, just a new command line, so I think it worked.

Now I am trying to run the xml2h script I've downloaded.

I am having a problem with the right syntax though.

So in the example (which I posted above), the user simply type the following at the python shell prompt: "xml2h.py /tmp/song.xml ~/prog/Playtune/songs/spng.h".

I'm not sure of the reason (different python version?) I can't just type a script name at the Python shell prompt, I've found (thanks google!) "execfile "script.py". (Substituting an actual script name.)

What I can't figure out now is the proper syntax for the input and output file. I've tried 5 different variations, but it doesn't like any of them.

From the Windows DOS-like command prompt you can invoke the Python program and pass as a command line argument to that program a script name, which the Python program (interpreter) will then run. Further command line arguments are passed to the Python script by the Python interpreter.

The way to tell what should go where is that Python source code goes in a Python shell, and non-Python source code if it's a command will go in an operating system (e.g. Windows) command prompt. (I mention this because of Linux and OS X, since there is some variability among the three, especially for Windows, so if you see commands elsewhere they may not work.) If the command begins with "python " then you're probably trying to invoke the interpreter, and so it doesn't work in the Python shell since "python" isn't inherently valid Python source code.

Join the #python-forum IRC channel on irc.freenode.net for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from

When I try to run the xml2h.py[/] script, I get an: "ImportError: No module names BeautifulSoup" error. This is why I think I need to run the [i]pip install BeautifulSoup command as mentioned on the BeautifulSoup page. (I hope that's the problem at least.)

Basically, you have to watch out, whether you are looking into a problem within python or with you operating system (in this case win7). You will probably face some of the latter, as unfortunately Python is not shipped with Windows. On Linux, that is so. That is why many tutorials online may assume you use Linux. On the other hand, this is easy to fix, as soon as you know what to look for.

Another suggestion, add your python folder to your Windows' System Variable "Path". Then you can type "python" anywhere, and move your projects to their own folders, etc.

Did you run "python ez_setup.py" in a Windows shell and it succeeded? There might be administrator issues if it did seem to succeed. Also, you may need to manipulate your PATH variable (as mentioned above) for reasons that always baffle me (installers should absolutely be doing this for you, I'm very sorry they do not).

Join the #python-forum IRC channel on irc.freenode.net for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from

I've made some pretty good progress. In fact, I think it's worked! (I'll of course have to move on to the next step and get this on my Arduino chip to really know, but I did get a .h file, which is what I needed.

The PIP install did work properly, but it was as you suggested a path issue. I added a path for \python27\pip and all the other pip directories I saw, but pip.exe actually gets put in the \python27\scripts directory. I added a path entry to that directory and the BeautifulSoup install with [i]pip[/] went as expected.

After that I ran the script, from the Windows shell as suggested and it worked perfectly.

Thanks so much for all the help. I truly appreciate it.

Is there a good basic tutorial to python somewhere on youtube? I looked for one, but nothing I found seemed that great. It would be nice to know more about all of this stuff.

The best tutorial i have found is "How to Think Like a Computer Scientist" pyhthon 2 version. I have been getting into python for like a month now. For 25 days i learned virtually nothing. Then i found the above book/tutorial, I learned more from that in a few hours than i did from other sources all month. Also, the man who wrote the book is great. If you have any questions, or even sugestions, you can just email him. He usually gets back to me within two days.

Yeah, "How to think like a computer scientist" is my favorite written tutorial although the question here was about a video tutorial. (By the way, that tutorial is my favorite, but I consider the title to be quite misleading!)

Join the #python-forum IRC channel on irc.freenode.net for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from

Yes, the title is stupid. Actually I almost didnt use this tutorial because of it. Man am i glad i did. I have looked at alot of them, interactive tuts, video tuts, all of them. And httlacs is by far the best.