Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The Gunslinger
Jul 24, 2004

Do not forget the face of your father.
Fun Shoe
I decided to pick up Python, I have a fair amount of experience with Perl and C++ but want to update my skillset a bit. My laptop that runs Linux is having hardware problems so I decided to fart around on my Windows gaming PC with this. I'm working through a tutorial book but just encountered an issue.

They want you to mess around with turtle which is part of the standard library. If I call my script or invoke Python in a command shell from my base user directory (C:\users\TGS) I can import turtle and work with it just fine. If I try to import it from a folder on my desktop, I can't. I just get an unknown attribute error since it can't find the library. I've checked the PATH and the installation directory for Python is there so uh, anyone know what gives?

Adbot
ADBOT LOVES YOU

The Gunslinger
Jul 24, 2004

Do not forget the face of your father.
Fun Shoe
I just uninstalled Python and installed Anaconda instead. Having the same problem though.

code:
C:\Users\TGS\Desktop\Python>python bob.py
Traceback (most recent call last):
  File "bob.py", line 8, in <module>
    import turtle
  File "C:\Users\TGS\Desktop\Python\turtle.py", line 2, in <module>
    bob = turtle.Turtle()
AttributeError: module 'turtle' has no attribute 'Turtle'
Anaconda is installed and has set itself in my Path. I just want to be able to work from any directory and import libraries from the standard libs. Do I need to specify the folder when I do this? I don't really understand why its looking for turtle.py inside of that directory instead of in C:\users\TGS\Anaconda3. After setting the PYTHONPATH it still does the same thing.

I can only import sys and print sys.path if I run python from a shell in C:\users\TGS. It shows the default Anaconda install directory, scripts sub folders and etc.

I just want to be able to run scripts from any directory instead of being locked to my user directory.

The Gunslinger
Jul 24, 2004

Do not forget the face of your father.
Fun Shoe
Haha holy poo poo I hope it's that simple, just got into work but I'll RDP into my machine later and check. Thanks man.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply