How to install win32com module in a virtualenv?

后端 未结 3 852
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 07:27

I have installed both virtualenv and pywin32 on my Windows 7 64-bit laptop, and each of them seems to work, but not with each other.

More s

3条回答
  •  死守一世寂寞
    2020-12-29 07:30

    Create a virtualenv and activate it: cd c:\Users\ernesto.luzon virtualenv --no-site-packages py351env py351env\Scripts\activate

    From here, you have two options:

    1. Download pywin32 from sourceforge project: http://sourceforge.net/projects/pywin32/files/pywin32/

    2. Download pywin32 from unofficial (but very helpful) binary site: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32

    Make sure you download the correct version for the Python Interpreter installed in your environment, otherwise you will encounter ImportError: DLL load failed: %1 is not a valid Win32 application later.

    If you downloaded from sourceforge, install it using easy_install: (py351env) C:\Users\ernesto.luzon\Downloads>easy_install pywin32-220.win-amd64-py3.5.exe

    If you downloaded from gohlke, install it using pip: (py351env) C:\Users\ernesto.luzon\Downloads>pip install pywin32-220-cp35-none-win_amd64.whl

    In case you encounter ImportError: DLL load failed: The specified module could not be found error later on, you need these additional steps:

    Run the post install script: (py351env) C:\Users\ernesto.luzon>python py351env\Scripts\pywin32_postinstall.py -install Copied pythoncom35.dll to C:\Users\ernesto.luzon\py351env\pythoncom35.dll Copied pywintypes35.dll to C:\Users\ernesto.luzon\py351env\pywintypes35.dll ....

    Notice where it copied the 'pythoncom35.dll' and 'pywintypes35.dll' files. You need to move these files to the folder: C:\Users\ernesto.luzon\py351env\Lib\site-packages\win32

提交回复
热议问题