0

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

  • Doing `SET PYTHONPATH=whatever` on the command line only affects things you run later in the same command-line window. If you want to set an environment variable permanently, for all apps opened by Explorer or any command-line window or anywhere else, you need to use the Control Panel. The details are different on different versions of Windows, but I'm sure there's a good answer on SuperUser that explains how to do it if you can't figure it out. (It's not as easy as it should be—partly because every time Microsoft makes it "easier" they make all the existing answers/blogs/etc. wrong…) – abarnert May 02 '18 at 20:54
  • Thank you, abarnert. I'm not sure that I even should be doing it on the command line. I can't decipher whether this is something I should do there or elsewhere. What is the way to get python to recognize a new path? It's so straightforward in MATLAB... – Sakyataksis May 02 '18 at 22:14
  • If you want to set an environment variable permanently, you need to use the Control Panel. If you don't know what that means, that's a question for a site like Super User, not Stack Overflow. – abarnert May 02 '18 at 22:18
  • You can also change directories in IDLE to the folder where your Python module is saved, using something like [this](https://stackoverflow.com/a/15821215/7315159). – Niayesh Isky May 03 '18 at 04:07

1 Answers1

0

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.

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52