-3

I have to move the script to my Desktop in order for it to run. I believe this has something to do with my working path but I'm missing what that could be.

My directory structure is this:

/dir/dir/Python/Project/script.py

My script is very basic until I can get this basic part to work.

import getpass 

p = getpass.getpass()
print("You entered:", p) 
Druta Ruslan
  • 7,171
  • 2
  • 28
  • 38
just1han85
  • 313
  • 1
  • 4
  • 14
  • Is your code formatted like shown. Without a line break before print? – Klaus D. May 22 '18 at 04:27
  • can you run other code? Or is the `getpass` package the only thing that is not working? Have a look at [this](https://stackoverflow.com/questions/5137497/find-current-directory-and-files-directory), it might give some insight into your working path. – J.A.Cado May 22 '18 at 05:02
  • The getpass module does seem to be the only module where I have this issue. I have other scripts where I’m importing other modules and those haven’t thrown any issues yet. Thoughts? – just1han85 May 22 '18 at 11:50

1 Answers1

0

For my environment of python 3.5.2 it works fine.

I guess the syntax might be a problem. Have a look at the script attached below.

>>> import getpass
>>> p = getpass.getpass()
Password: 
>>> print("You entered:", p)
You entered: XYZ
>>> p = getpass.getpass() print("You entered:", p)
  File "<stdin>", line 1
  p = getpass.getpass() print("You entered:", p)
                          ^
SyntaxError: invalid syntax
SilentFlame
  • 487
  • 5
  • 15
  • Please post your answer as formatted text not as an image. Also if you do not answer the question, use a comment as soon as you have enough reputation. And consider that the code was just displayed badly since the OP did not format it properly here on SO. – Klaus D. May 22 '18 at 04:23
  • @KlausD. updated the answer with the text. Will keep these in mind from next time. – SilentFlame May 22 '18 at 04:28
  • @SilentFlame, I'm running version 3.6.2 and the syntax works for me but only when I run the script from my Desktop directory. If I try and run it from a different directory, it throws an error and and says "TypeError: 'module' object is not callable". – just1han85 May 22 '18 at 12:35
  • @justin_0104 sorry but it run's fine on my system, I really don't know what might be the problem. If you can attach the error, I might be able to help you. – SilentFlame May 23 '18 at 07:52