Jes*_*ers 5 python python-2.x pycharm
我正在2020.1.2Windows 10 上的Pycharm ( ) 中处理Python 项目。
对于这个项目,我不能使用标准的 Python 解释器,我必须使用我自己的位于C:\some\path\here\python\27_64\python.exe(Python 2.7.3) 的解释器。
背景故事可能很重要:
我已将此路径添加到我自己和所有用户的系统路径中,并将其放在前面%LOCALAPPDATA%\Microsoft\WindowsApps以防止 Microsoft 商店在我尝试python在命令行上运行时弹出- 但是我不喜欢这种更改到 path 变量产生了影响,因为 Microsoft 商店仍然会弹出。
我可以通过运行启动 Python shell C:\some\path\here\python\27_64\python.exe,所以我知道它在技术上是有效的。当我这样做时;的sys.path如下:
['', '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']
Run Code Online (Sandbox Code Playgroud)
无论如何,当我尝试运行 Python 控制台(甚至不是我的脚本)时,这是我在 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
Run Code Online (Sandbox Code Playgroud)
我已经转到Settings> Project:[name]>Project Interpreter并将其设置为C:\some\path\here\python\27_64\python.exe(并重新启动 Pycharm 以确保)。那说; 在设置窗口中没有显示包,它声称找不到 Python 打包工具。
当我单击链接安装它们(红色圈出)时,由于此错误而无法安装它们:
ImportError: cannot import name _remove_dead_weakref
Run Code Online (Sandbox Code Playgroud)
我需要更改其他变量或设置吗?
谢谢
编辑
卸载我路径上的第一个 Python ( C:\\another_place\\Python_2.7.3_x64\\python27.zip) 只会让一切变得更糟
编辑 2
我PATH手动将变量添加到 Python 控制台设置和 PyCharm 中的运行/调试设置(并重新启动程序),结果仍然相同
我有类似的问题。此过程解决了我的问题。请尝试以下操作:
print(os.environ['PATH'])使用相同的解释器在系统终端中运行
复制结果并将其作为 PATH 环境变量添加到您的运行/调试配置中
对 Python 控制台设置执行相同操作
我希望它会起作用。