First time here? Check out the FAQ!
1

Python path

Hello everyone, What directory to be used as Python Path in Python configuration option? I am also getting this error: builtins.ImportError: cannot import name 'randint' from 'random'

Many Thanks, Galib

galib20's avatar
11
galib20
asked 2019-06-17 00:16:33 -0600
Wingware Support's avatar
4k
Wingware Support
updated 2019-06-17 08:35:09 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

Do you have a file named random.py? I suspect that you're importing that file instead of random from the standard library. You can use print(random) to see the file used. In general, directories that your code is in should be added to the python path.

Wingware Support's avatar
4k
Wingware Support
answered 2019-06-17 04:01:56 -0600
edit flag offensive 0 remove flag delete link

Comments

On running print(random): builtins.NameError: name 'random' is not defined

galib20's avatar galib20 (2019-06-17 20:12:27 -0600) edit

My Python configuration: Executable: C:\Users\galib20\AppData\Local\Programs\Python\Python37-32\python.exe.

Python path: as above.

On running print(random) builtins.NameError: name 'random' is not defined

galib20's avatar galib20 (2019-06-17 20:15:22 -0600) edit

print(random) won't work unless you do 'import random'. I think you have 'from random import randint' or something like that so the symbol 'random' is not being defined by the import statement. But if you add 'import random' temporarily then you can use the print to see what is being imported.

Wingware Support's avatar Wingware Support (2019-06-17 20:22:19 -0600) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer