0

I am on Windows 10, attempting to get Python 3 set up so that I can use pip to download modules and packages.

I'm able to download and install packages using python -m pip install [package]; however, I still cannot import them into my code.

I opened IDLE, and on File -> Path Browser I found that my path was actually looking in folders under

C:\Program Files (x86)\Microsoft Visual Studio\Shared

Not a problem - I opened up my Environment Variables and under System variables I added a new PYTHONPATH, with the folder being under C:\Program Files (x86)\Python38-32\Lib\site-packages, which is where pip is actually installing modules and packages. This was suggested on another Stack Overflow answer over here.

This seemed to work fine - I restarted Windows, opened IDLE again and now under Path Browser the ...\Lib\site-packages folder is there. However, when I try to import a package I've installed, for example Numpy, I get this mess (which I've never seen before):

>>> import numpy
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import numpy
  File "C:\Program Files (x86)\Python38-32\Lib\site-packages\numpy\__init__.py", line 138, in <module>
    from . import _distributor_init
  File "C:\Program Files (x86)\Python38-32\Lib\site-packages\numpy\_distributor_init.py", line 26, in <module>
    WinDLL(os.path.abspath(filename))
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

This happens for all of the packages that I installed with pip. Now I'm not sure what to do.

Also, I have both Visual Studio and the newest Python 3.8 version installed on my laptop and it doesn't seem to have this issue. Anything I install with pip is in the correct site-packages folder and I can import it without a problem. Any advice I could have on this issue would be hugely appreciated.

Rowan
  • 351
  • 2
  • 13
  • 1) Are you one a 32-bit system (my guess is no)? Otherwise I would uninstall your current python and install the 64-bit version. 2) When you install python, save yourself the trouble and just select the box that says "Add Python to PATH." That way you don't have to deal with editting the environment variables yourself. – Error - Syntactical Remorse Jul 31 '20 at 18:12
  • Also appears you have `Python37_64` and `Python38-32` installed on your computer and your paths are mismatched. My suggestion, uninstall all version of python from your computer, reinstall only the version you want (64-bit), make sure to add to path during install. Lastly make sure no other version of python is within your `PATH` environment variable. – Error - Syntactical Remorse Jul 31 '20 at 18:14

0 Answers0