Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm: DLL load failed: The specified procedure could not be found

I am working on a Python project in Pycharm (2020.1.2) on Windows 10.

For this project, I cannot use the standard Python interpreter, I have to use my own located at C:\some\path\here\python\27_64\python.exe (Python 2.7.3).

Backstory may be important:

I have added this path to the system path for both myself and all users, and placed it ahead of %LOCALAPPDATA%\Microsoft\WindowsApps to try to prevent the Microsoft store from popping up whenever I try to run python on the command line - however I don't feel like this change to the path variable has made a difference, as the Microsoft store still pops up.

I can start a Python shell by running C:\some\path\here\python\27_64\python.exe, so I know it technically works. When I do so; the sys.path is as follows:

['', 'C:\\another_place\\Python_2.7.3_x64\\python27.zip',
'C:\\some\\path\\here\\python\\27_64\\DLLs',
'C:\\some\\path\\here\\python\\27_64\\lib',
'C:\\some\\path\\here\\python\\27_64\\lib\\plat-win',
'C:\\some\\path\\here\\python\\27_64\\lib\\lib-tk',
'C:\\some\\path\\here\\python\\27_64',
'C:\\some\\path\\here\\python\\27_64\\lib\\site-packages']

Anyway, when I try to run a Python console (not even my script), this is the message I get in Pycharm:

C:\some\path\here\python\27_64\python.exe "C:\Program Files\JetBrains\PyCharm 2020.1.1\plugins\python\helpers\pydev\pydevconsole.py" --mode=client --port=59771
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2020.1.1\plugins\python\helpers\pydev\pydevconsole.py", line 5, in <module>
    from _pydev_comm.pydev_rpc import make_rpc_client, start_rpc_server, start_rpc_server_and_make_client
  File "C:\Program Files\JetBrains\PyCharm 2020.1.1\plugins\python\helpers\pydev\_pydev_comm\pydev_rpc.py", line 1, in <module>
    import socket
  File "C:\some\path\here\python\27_64\lib\socket.py", line 47, in <module>
    import _socket
ImportError: DLL load failed: The specified procedure could not be found.
Process finished with exit code 1

I have gone to Settings>Project:[name]>Project Interpreter and set it to C:\some\path\here\python\27_64\python.exe (and rebooted Pycharm to be sure). That said; in the settings window no packages are shown and it claims that Python packaging tools can not be found. picture of Pycharm settings window, the file path is to the interpreter is C:\some\path\here\python\27_64\python.exe, a message says the Python packaging tools can't be found, the link "install packages" is circled in red When I click the link to install them (circled in red), they can not be installed due to this error:

ImportError: cannot import name _remove_dead_weakref

Are there other variables or settings I need to change?

Thanks

EDIT

Uninstalling the first Python on my Path (C:\\another_place\\Python_2.7.3_x64\\python27.zip) just makes everything so much worse

EDIT 2 I added the PATH variable manually to both the Python console settings and to the Run/Debug settings in PyCharm (and restarted the program), the result is still the same

like image 851
Jessica Chambers Avatar asked Jun 12 '20 15:06

Jessica Chambers


2 Answers

I had a similar issue. This procedure fixed my issue. Try the following:

  • run print(os.environ['PATH']) in the system terminal using the same interpreter

  • copy the result and add as PATH environment variable to your Run/Debug Configuration

  • do the same for Python Console settings

I hope it will work.

like image 115
Ransaka Ravihara Avatar answered Oct 17 '22 03:10

Ransaka Ravihara


It seems that the interpreter is not being recognized by the windows as a result of which you are unable to install packages. Also, I suppose the interpreter should be present in the bin folder of your python folder. The interpreter does not have a .exe extension.

I would suggest installing anaconda python 2.7 64 Bit windows package installer and using the condo environment and work on python 2.7

Here is a link I found for Python 2.7 on Windows hope this helps: https://docs.python.org/2/faq/windows.html

like image 2
Riya_Dhar Avatar answered Oct 17 '22 03:10

Riya_Dhar