简体   繁体   中英

IDLE's path, not Windows' path: How do I edit Python's path in MS Windows to include a .py module?

I don't think the other questions on stack overflow that sound like this are actually this question. (I did read several of them.)

I downloaded a module, thinkbayes.py. When I'm in IDLE, typing "from thinkbayes import pmf" gives the following.

Traceback (most recent call last): File "", line 1, in from thinkbayes import pmf ModuleNotFoundError: No module named 'thinkbayes'

I copied thinkbayes.py to many directories where python is installed, and that didn't help. So, I searched online for this and found recommendations like:

SET SAVE=%PYTHONPATH%

SET PYTHONPATH=.

python scripts/doit.py

SET PYTHONPATH=%SAVE%

(in stack overflow)

I tried that (and other recommendations) both in IDLE and in the Windows command-line interface. Neither one recognizes those commands. I changed directories to C: -- no improvement.

What am I missing here that everyone else knows? To repeat, I'm trying to get a Python 3 installation to recognize a .py file that I've copied into the 'Scripts' directory, the 'include' directory, etc.

Thanks,

Sakyataksis

Do not put a python file in pythonxy/include, which is for C .h header files.

pythonxy/scripts is for startup files and support files for startup files. But this only works if pythonxy/scripts is on the system PATH. The installer asks you if you want this. But this in turn is problematic if you have more than one python version installed.

On Windows, downloaded files and packages should generally go in pythonxy/Lib/site-packages. If you use pip to get file xyz, this is where it will put it. Then when you run pythonxy, import xyz should work.

None of this has anything to do with IDLE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM