Pydev wine pythonpath问题/控制台初始化超时问题(Pydev wine pythonpath issues/console initialization timeout issue)

我在Pydev中设置了一个调用一个小脚本的解释器:

#!/bin/bash WINEDEBUG=fixme-all WINEPREFIX=/home/dal/wine/Python wine C:\\Python27\\python.exe "$@"

启动一个Windows版本的python实例(我需要它才能进入仅限Windows的ODBC数据库驱动程序)。 这很好用,我能够启动一个控制台,使用该解释器运行脚本等。

但是 - 我现在需要添加对存储我需要访问的一组模块的目录的引用 - 但是,python的windows版本需要一个PYTHONPATH,其元素用分号分隔,在Z:\ home \ blah \无论格式,而不是冒号和/ home / blah /等等。

Pydev不会让我在首选项中添加任意路径 - > pydev - > interpreters - > libraries部分(它希望我在文件选择器中找到路径,然后创建一个/ home / blah /来自所选内容的任何字符串) 。

尝试使用环境选项卡将PYTHONPATH设置为$ {PYTHONPATH} \; Z:\ path \ I \ need会导致pydev告诉我忘记它(它不会让我在该对话框中专门设置PYTHONPATH)。

添加PYTHONPATH=${PYTHONPATH}\;Z:\\path\\I\\need shell脚本通过wine调用python的windows版本是我能想到的最后一件事,但它会导致一些不好的事情发生在PyDev的:

Error initializing console. Unexpected error connecting to console. Failed to recive suitable Hello response from pydevconsole. Last msg received: Failed to read server's response: Connection refused

是的,它没有回复。

我可以手动:

import sys sys.path.append(r'Z:\really\long\path\that\I\dont\want\to\type\often')

事情会奏效,但是......我真的很想不必每次都打字。

将上面的内容放在一个文件中并将PYTHONSTARTUP环境变量指向它解决了从终端运行的python实例的问题,但在pydev中运行的python实例似乎根本没有查看PYTHONSTARTUP

通过我在晚上的这个时间提出的所有想法(简单地将整个模块目录导入我在pydev中工作的每个项目,这看起来......不优雅,至少可以说),是否有人还有想过如何通过圆孔推动这个特殊的方形钉?

更新:模块目录实际上是通过sshfs挂载的,并且在pythonpath中,从终端启动python解释器的实例有点慢(35秒ish)。 试图从pydev中启动一个控制台似乎在<15秒内超时,所以我想知道这里需要什么只是某种方式来增加等待解释器响应的时间,它在放弃之前尝试启动,如果输出片段末尾的'连接被拒绝'消息意味着(正如该片段的其余部分似乎暗示的那样)'在我放弃之前未接受连接'超过'解释器告诉我显然连接不会发生'?

I've set up an interpreter in Pydev that calls a small script:

#!/bin/bash WINEDEBUG=fixme-all WINEPREFIX=/home/dal/wine/Python wine C:\\Python27\\python.exe "$@"

to fire up an instance of the windows version of python (which I need in order to get to windows-only ODBC database drivers). This much works fine, I am able to start a console, run scripts using that interpreter etc.

However - I now need to add a reference to a directory storing a bunch of modules that I need to access - however the windows version of python wants a PYTHONPATH that has elements separated by semicolons and in Z:\home\blah\whatever format, rather that colons and /home/blah/whatever.

Pydev won't let me add arbitrary paths in the preferences -> pydev -> interpreters -> libraries section (it wants me to find the path in a file picker, then creates a /home/blah/whatever string from what was picked).

Attempting to use the enviroment tab to set PYTHONPATH to ${PYTHONPATH}\;Z:\path\I\need results in pydev telling me to forget about it (it won't let me set PYTHONPATH specifically from that dialog).

Adding PYTHONPATH=${PYTHONPATH}\;Z:\\path\\I\\need to the shell script which calls the windows version of python via wine was the last thing I could think of, but it causes something bad to happen in pydev:

Error initializing console. Unexpected error connecting to console. Failed to recive suitable Hello response from pydevconsole. Last msg received: Failed to read server's response: Connection refused

yup, it fails to recive.

I can manually:

import sys sys.path.append(r'Z:\really\long\path\that\I\dont\want\to\type\often')

and things will work, but...I'd really like to not have to type that each time.

putting the above in a file and pointing the PYTHONSTARTUP environmental variable at it solves that problem for a python instance running from the terminal, but the python instance running inside pydev doesn't seem to look at PYTHONSTARTUP at all

Gone through just about all the ideas I can come up with at this time of night (short of simply importing the whole modules directory into every project I work on in pydev, which seems...inelegant, to say the least), does anyone else have a thought on how to push this particular square peg through the round hole?

Update: the module directory is actually mounted via sshfs, and with it in the pythonpath, launching an instance of the python interpreter from a terminal is somewhat slow (35sec ish). Attempting to launch a console from within pydev appears to time out in < 15sec, so I'm wondering if what's needed here is just some way to increase the amount of time it waits for a response from the interpreter it's trying to launch before giving up, and if the 'connection refused' message at the end of the output snippet means (as the rest of that snippet seems to suggest) 'connection not accepted before I gave up' more so than 'interpreter told me explicitly connection was not going to happen'?

最满意答案

我会尝试使用sys.path

import sys print sys.path # print a list of locations Python searches for modules sys.path.append('Z:\\path\\I\\need') # now import your modules import my_module

关于PYTHONPATH方法,您也可以尝试使用单引号 - 当前方法无法正确转义,并且\\n被解释为换行符。

PYTHONPATH=${PYTHONPATH}\;'Z:\\path\\I\\need'

I would try playing around with sys.path

import sys print sys.path # print a list of locations Python searches for modules sys.path.append('Z:\\path\\I\\need') # now import your modules import my_module

Regarding your PYTHONPATH method, you could also try putting into single quotes - your current method doesn't escape properly, and \\n is interpreted as a newline character.

PYTHONPATH=${PYTHONPATH}\;'Z:\\path\\I\\need'Pydev wine pythonpath问题/控制台初始化超时问题(Pydev wine pythonpath issues/console initialization timeout issue)

我在Pydev中设置了一个调用一个小脚本的解释器:

#!/bin/bash WINEDEBUG=fixme-all WINEPREFIX=/home/dal/wine/Python wine C:\\Python27\\python.exe "$@"

启动一个Windows版本的python实例(我需要它才能进入仅限Windows的ODBC数据库驱动程序)。 这很好用,我能够启动一个控制台,使用该解释器运行脚本等。

但是 - 我现在需要添加对存储我需要访问的一组模块的目录的引用 - 但是,python的windows版本需要一个PYTHONPATH,其元素用分号分隔,在Z:\ home \ blah \无论格式,而不是冒号和/ home / blah /等等。

Pydev不会让我在首选项中添加任意路径 - > pydev - > interpreters - > libraries部分(它希望我在文件选择器中找到路径,然后创建一个/ home / blah /来自所选内容的任何字符串) 。

尝试使用环境选项卡将PYTHONPATH设置为$ {PYTHONPATH} \; Z:\ path \ I \ need会导致pydev告诉我忘记它(它不会让我在该对话框中专门设置PYTHONPATH)。

添加PYTHONPATH=${PYTHONPATH}\;Z:\\path\\I\\need shell脚本通过wine调用python的windows版本是我能想到的最后一件事,但它会导致一些不好的事情发生在PyDev的:

Error initializing console. Unexpected error connecting to console. Failed to recive suitable Hello response from pydevconsole. Last msg received: Failed to read server's response: Connection refused

是的,它没有回复。

我可以手动:

import sys sys.path.append(r'Z:\really\long\path\that\I\dont\want\to\type\often')

事情会奏效,但是......我真的很想不必每次都打字。

将上面的内容放在一个文件中并将PYTHONSTARTUP环境变量指向它解决了从终端运行的python实例的问题,但在pydev中运行的python实例似乎根本没有查看PYTHONSTARTUP

通过我在晚上的这个时间提出的所有想法(简单地将整个模块目录导入我在pydev中工作的每个项目,这看起来......不优雅,至少可以说),是否有人还有想过如何通过圆孔推动这个特殊的方形钉?

更新:模块目录实际上是通过sshfs挂载的,并且在pythonpath中,从终端启动python解释器的实例有点慢(35秒ish)。 试图从pydev中启动一个控制台似乎在<15秒内超时,所以我想知道这里需要什么只是某种方式来增加等待解释器响应的时间,它在放弃之前尝试启动,如果输出片段末尾的'连接被拒绝'消息意味着(正如该片段的其余部分似乎暗示的那样)'在我放弃之前未接受连接'超过'解释器告诉我显然连接不会发生'?

I've set up an interpreter in Pydev that calls a small script:

#!/bin/bash WINEDEBUG=fixme-all WINEPREFIX=/home/dal/wine/Python wine C:\\Python27\\python.exe "$@"

to fire up an instance of the windows version of python (which I need in order to get to windows-only ODBC database drivers). This much works fine, I am able to start a console, run scripts using that interpreter etc.

However - I now need to add a reference to a directory storing a bunch of modules that I need to access - however the windows version of python wants a PYTHONPATH that has elements separated by semicolons and in Z:\home\blah\whatever format, rather that colons and /home/blah/whatever.

Pydev won't let me add arbitrary paths in the preferences -> pydev -> interpreters -> libraries section (it wants me to find the path in a file picker, then creates a /home/blah/whatever string from what was picked).

Attempting to use the enviroment tab to set PYTHONPATH to ${PYTHONPATH}\;Z:\path\I\need results in pydev telling me to forget about it (it won't let me set PYTHONPATH specifically from that dialog).

Adding PYTHONPATH=${PYTHONPATH}\;Z:\\path\\I\\need to the shell script which calls the windows version of python via wine was the last thing I could think of, but it causes something bad to happen in pydev:

Error initializing console. Unexpected error connecting to console. Failed to recive suitable Hello response from pydevconsole. Last msg received: Failed to read server's response: Connection refused

yup, it fails to recive.

I can manually:

import sys sys.path.append(r'Z:\really\long\path\that\I\dont\want\to\type\often')

and things will work, but...I'd really like to not have to type that each time.

putting the above in a file and pointing the PYTHONSTARTUP environmental variable at it solves that problem for a python instance running from the terminal, but the python instance running inside pydev doesn't seem to look at PYTHONSTARTUP at all

Gone through just about all the ideas I can come up with at this time of night (short of simply importing the whole modules directory into every project I work on in pydev, which seems...inelegant, to say the least), does anyone else have a thought on how to push this particular square peg through the round hole?

Update: the module directory is actually mounted via sshfs, and with it in the pythonpath, launching an instance of the python interpreter from a terminal is somewhat slow (35sec ish). Attempting to launch a console from within pydev appears to time out in < 15sec, so I'm wondering if what's needed here is just some way to increase the amount of time it waits for a response from the interpreter it's trying to launch before giving up, and if the 'connection refused' message at the end of the output snippet means (as the rest of that snippet seems to suggest) 'connection not accepted before I gave up' more so than 'interpreter told me explicitly connection was not going to happen'?

最满意答案

我会尝试使用sys.path

import sys print sys.path # print a list of locations Python searches for modules sys.path.append('Z:\\path\\I\\need') # now import your modules import my_module

关于PYTHONPATH方法,您也可以尝试使用单引号 - 当前方法无法正确转义,并且\\n被解释为换行符。

PYTHONPATH=${PYTHONPATH}\;'Z:\\path\\I\\need'

I would try playing around with sys.path

import sys print sys.path # print a list of locations Python searches for modules sys.path.append('Z:\\path\\I\\need') # now import your modules import my_module

Regarding your PYTHONPATH method, you could also try putting into single quotes - your current method doesn't escape properly, and \\n is interpreted as a newline character.

PYTHONPATH=${PYTHONPATH}\;'Z:\\path\\I\\need'