Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: DLL load failed while importing win32file #8

Closed
csnam opened this issue Feb 10, 2020 · 5 comments
Closed

ImportError: DLL load failed while importing win32file #8

csnam opened this issue Feb 10, 2020 · 5 comments

Comments

@csnam
Copy link

csnam commented Feb 10, 2020

i had proceed according to the install instruction
When I ran the demonstration, I got the following error.

importError: DLL load failed while importing win32file

I'd appreciate it if someone would help me

command list

conda install pytorch torchvision -c pytorch
conda install opencv
pip install git+https://github.com/facebookresearch/fvcore
pip install cython;
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
#two file modify argument_spec.h , cast.h
"C:\Program Files (x86)\Microsoft Visual Studio\2019\community\VC\Auxiliary\Build\vcvars64.bat"
cd detectron2
python setup.py build develop

there was no error until the command above

execute demo

python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input input1.jpg --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl`

...
...
File "C:\Users\CSNAM\Anaconda3\envs\detectron_env\lib\site-packages\portalocker_init_.py", line 4, in
from . import portalocker
File "C:\Users\CSNAM\Anaconda3\envs\detectron_env\lib\site-packages\portalocker\portalocker.py", line 9, in
import win32file
ImportError: DLL load failed while importing win32file

Did i miss something ?

@jefflomax
Copy link

jefflomax commented Feb 10, 2020

I also had to set num_devices to 1 in evaluator.py (there may be a more elegant way to disable torch.distributed). My environment is a little different as I'm building against CUDA 10.0 instead of 10.1. pip list on my environment shows portalocker 1.5.2

And your test ran fine for me:

python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input "C:\programs\pytorch\detectron2\datasets\coco\val2017\000000000139.jpg" --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
[02/10 16:16:28 detectron2]: Arguments: Namespace(confidence_threshold=0.5, config_file='configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml', input=['C:\\programs\\pytorch\\detectron2\\datasets\\coco\\val2017\\000000000139.jpg'], opts=['MODEL.WEIGHTS', 'detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl'], output=None, video_input=None, webcam=False)
WARNING [02/10 16:16:28 d2.config.compat]: Config 'configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml' has no VERSION. Assuming it to be compatible with latest v2.
model_final_f10217.pkl: 178MB [00:07, 25.4MB/s]
[02/10 16:16:42 detectron2]: C:\programs\pytorch\detectron2\datasets\coco\val2017\000000000139.jpg: detected 21 instances in 2.83s

@jefflomax
Copy link

What version of Python? mhammond/pywin32#1431

@csnam
Copy link
Author

csnam commented Feb 11, 2020

With your advice, the error was eliminated and it was successfully implemented. Thank you.
i had needed the below command
"conda install pywin32"

@csnam csnam closed this as completed Feb 11, 2020
@nickums
Copy link

nickums commented Oct 15, 2020

my 'conda install pywin32' gives me
CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json
.....
SSLError(MaxRetryError('HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))'))

@fingoldo
Copy link

fingoldo commented Jun 7, 2022

What helped me was issuing the following commands in the x64 command line:

cd C:\ProgramData\Anaconda3\Scripts
python pywin32_postinstall.py -install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants