简体   繁体   中英

Python extension packages not found unless python.exe called from command line

I have Python 3.5.2 installed on windows. I've installed several wheels using 'pip install'. I did this with administrative privileges

If I am at a command line and type 'python.exe', I get the python command line and can type ">>> import numpy" and it will work fine. However, if I open IDLE or python.exe directly from the windows desktop environment I will get the following message when importing any extension:

Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'numpy'

Now its important to note my local account on my laptop is not an admin account. On another laptop I installed the same extensions with the same python version and do not have this issue (local account is admin). This is the only difference I know of. Both Windows 7 x64 Pro machines. I'm thinking it is an issue that IDLE/desktop launched python.exe does not know to look for the extensions. Is there something I need to add to PATH environmental variable in Windows?

Thanks


Ok, python path was missing from PATH environmental variable added it, no change. I then checked python versions from both the command line and idle/python.exe and got these results:

3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64

bit (AMD64)]

3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)]

So it sounds like it's related to anaconda. I didn't install the wheels in a virtual environment or with anaconda (at least not intentionally). So what's the deal? Maybe the anaconda path needs added to PATH?

have you tried checking which version of python are you running when you execute IDLE? It might be different from the version you execute from cmd, for example, you might have python 2.7 and 3.6 installed, but the one in the PATH is 3.6 and the IDLE one is 2.7

Issue was I failed to understand that Anaconda has its own Python installation and when I used 'pip install' for the wheels, the Anaconda directly was before the Python directory in the windows PATH variable, so it installed the wheels in the Anaconda environment and not the standard python environment. This is why there was a difference between launching python from a command line (Anaconda) and from the start menu (standard python). Solution was I made sure the Anaconda directory was first in PATH so scripts would launch with Anaconda environment, however, really there was no issue to begin with.

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