Ask Your Question

Python path

asked 2019-06-17 00:16:33 -0500

galib20 gravatar image

updated 2019-06-17 08:35:09 -0500

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

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-06-17 04:01:56 -0500

Do you have a file named 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.

edit flag offensive delete link more


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

galib20 gravatar imagegalib20 ( 2019-06-17 20:12:27 -0500 )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 gravatar imagegalib20 ( 2019-06-17 20:15:22 -0500 )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 gravatar imageWingware Support ( 2019-06-17 20:22:19 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-06-17 00:16:33 -0500

Seen: 1,113 times

Last updated: Jun 17 '19