它给我这个错误:
/usr/bin/python -u /opt/pycharm-community-4.5.1/helpers/pydev/pydev_run_in_console.py 58137 38816 /path/to/my/module.py
/usr/lib/python/site-packages/IPython/external/path.py:32: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import sys, warnings, os, fnmatch, glob, shutil, codecs, md5
/usr/lib/python/site-packages/IPython/iplib.py:58: DeprecationWarning: the sets module is deprecated
from sets import Set
Running /path/to/my/module.py
Traceback (most recent call last):
File "/opt/pycharm-community-4.5.1/helpers/pydev/pydev_run_in_console.py", line 69, in <module>
globals = run_file(file, None, None)
File "/opt/pycharm-community-4.5.1/helpers/pydev/pydev_run_in_console.py", line 29, in run_file
pydev_imports.execfile(file, globals, locals) # execute the script
File "/path/to/my/module.py", line 13, in <module>
import my.module.name
ImportError: No module named my.module.name
Process finished with exit code 1
Couldn't connect to console process.
如果我在BASH终端上运行它,它的执行就好了。它实际上也是从PyCharm执行得很好,但我不确定是什么改变了,我突然开始看到这种情况发生了。此外,它没有显示编辑器中缺少模块的任何错误,这表明至少编辑器可以在其搜索的路径中看到这些包。 PYTHONPATH也有这个目录。
答案 0 :(得分:-1)
从运行的环境变量中删除PYTHONPATH解决了问题。
修复步骤:
import android.util.Log;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
public class UdpServer implements Runnable {
UdpServer() {
run();
}
public void run() {
try {
String messageStr = "40320";
int server_port = 55555;
DatagramSocket datagramSocket = new DatagramSocket();
InetAddress host = InetAddress.getByName("10.1.10.14");
int msg_length = messageStr.length();
byte[] message = messageStr.getBytes();
DatagramPacket datagramPacket = new DatagramPacket(message, msg_length,host,
server_port);
datagramSocket.send(datagramPacket);
} catch (Exception e) {
}
}
}
的按钮
我仍然不明白发生了什么,但在删除它之前检查这个变量显示了多次添加的相同路径列表。这看起来很奇怪,所以我删除了这个变量并尝试了,它有效!