On Windows 7 machine, Pycharm (community or professional) and Python 3.4 (tried Anaconda 3 as well) were installed newly. There were not problems running Python scripts interactively in main editor. However, when I tried to select View > Tool Windows > Python Console, it generates the following error messages and more. Basically, I couldn't bring up a console window in Pycharm.
C:\Users\user\Anaconda3\python.exe -u C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevconsole.py 56743 56744
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydev_imports.py", line 21, in <module>
from SimpleXMLRPCServer import SimpleXMLRPCServer
ImportError: No module named 'SimpleXMLRPCServer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevconsole.py", line 20, in <module>
import pydevd_vars
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevd_vars.py", line 9, in <module>
from pydevd_xml import *
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydevd_xml.py", line 7, in <module>
from pydev_imports import quote
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pydev\pydev_imports.py", line 23, in <module>
from xmlrpc.server import SimpleXMLRPCServer
File "C:\Users\user\Anaconda3\lib\xmlrpc\server.py", line 108, in <module>
from http.server import BaseHTTPRequestHandler
File "C:\Users\user\Anaconda3\lib\http\server.py", line 660, in <module>
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
File "C:\Users\user\Anaconda3\lib\http\server.py", line 851, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "C:\Users\user\Anaconda3\lib\mimetypes.py", line 348, in init
db.read_windows_registry()
File "C:\Users\user\Anaconda3\lib\mimetypes.py", line 255, in read_windows_registry
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
TypeError: OpenKey() argument 2 must be str without null characters or None, not str
Process finished with exit code 1
Couldn't connect to console process.
-----------------these messages were showed up in "Python Console"-------------
You need to change your working directory. Go to File->Settings->Build, Execution, Deployment->Console->Python Console and then change or provide a directory where you have read and write access in the Working directory box.
The configuring of pycharm in the presence of various development configurations is a bit of a black art IMHO.
The most effective mechanism I've found for pinning this down is put random strings into the various settings dialogs, Interpreters, consoles, tests , servers and observe the command lines submitted to the interpreter VERY carefully.
Hardly a satisfactory approach but it will sort out what is going where and to a certain degree what effects what.
The other think that helps me are screenshots of the settings and testing dialogs of working installations.
Again, a bit rough and ready but it has got me up and running again after a long period of successful debugging followed by pycharm amnesia.
I had same problem. I reinstalled python and default directories have changed.
Then I just refreshed interpreter here File->Settings->Build, Execution, Deployment->Console->Python Console and here File->Settings->Project: <YOUR_PROJECT>->Project Interpreter.
If you will open new projects interpreter will need choose again (?)
I got it resolved by setting the interpreter in Preferences and project interpreter.
Related
I am writing a simple network scanner with python using scapy following is my code :
import scapy.all as scapy
def scan(ip):
scapy.arping(ip)
scan("192.168.1.1/24")
Error I am getting :
Traceback (most recent call last):
File "ipScanner.py", line 10, in <module>
scan("192.168.1.1/24")
File "ipScanner.py", line 8, in scan
scapy.arping(ip)
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/layers/l2.py", line 648, in arping
filter="arp and arp[7] = 2", timeout=timeout, iface_hint=net, **kargs) # noqa: E501
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/sendrecv.py", line 553, in srp
filter=filter, nofilter=nofilter, type=type)
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/supersocket.py", line 242, in __init__
super(L2bpfListenSocket, self).__init__(*args, **kwargs)
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/supersocket.py", line 62, in __init__
(self.ins, self.dev_bpf) = get_dev_bpf()
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/core.py", line 114, in get_dev_bpf
raise Scapy_Exception("No /dev/bpf handle is available !")
scapy.error.Scapy_Exception: No /dev/bpf handle is available !
Exception ignored in: <function _L2bpfSocket.__del__ at 0x105984c20>
Traceback (most recent call last):
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/supersocket.py", line 139, in __del__
self.close()
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/supersocket.py", line 211, in close
if not self.closed and self.ins is not None:
AttributeError: 'L2bpfSocket' object has no attribute 'ins'
Can anyone please help understand it.
NOTE: I am running it on mac OS.
I wrote this exact program when I first started programming with matching syntax, and it ran correctly on my systems when run as administrator. I develop on Linux and Windows rather than Mac, but I will offer what I can.
Are you running this script through your IDE or calling it from the shell?
I recommend only running it from the shell. This simply gives you more control over the files like specifying which version of python the script is, and if you need administrative privileges for a script, you can elevate the script permissions in the shell.
Also, in my OS, I was taught to always use, and have experienced the mistakes of forgetting this, always add:
#!/usr/bin/env python
as the first line of every script. At least in Linux, it tells the PC how to treat the file (it tells it to treat the file as a python file--yes I acknowledge that its already running it as python). I would check to see if that is valid for MacOS file system.
Most of what I have recommended so far comes down to no /dev/bpf handle is available, only ever being an issue for me when I'm not running script as an administrator (although Linux states permission denied). And I shouldn't leave out that using Anaconda on Windows in the past (before I understood the structure of my file systems) prevented me from using common modules like pygame and scapy. I could only guess in that case Anaconda prevented the PC from knowing where to find every piece of that module by making the computer think it had its own one of that module under Anaconda directory when it was in a different PATH.
So I finally got my python program working on my Mac (Catalina 10.15.4), but I am greeted with the following error when it is opened on another Mac (High Sierra 10.13.6.)
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 355, in <module>
_run()
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 340, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/dist/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 9, in <module>
from pysine import sine
File "pysine/__init__.pyc", line 14, in <module>
File "pysine/pysine.pyc", line 1, in <module>
File "pyaudio.pyc", line 116, in <module>
ImportError: dlopen(/Volumes/dist/Riff Gen.app/Contents/Resources/lib/python3.6/lib-dynload/_portaudio.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
in /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib
A simple tkinter test with various sounds and images works fine on the second machine, but not this script. I've tried adding all the packages manually, tried --nostrip, manually including 'libportaudio.2.dylib', and dozens of other ideas from countless outdated forums to no avail.
When the play function of my application is stripped, the app opens and crashes shortly thereafter - giving me the following error:
Traceback (most recent call last):
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 81, in <module>
_run()
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 66, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 2037, in <module>
root.mainloop()
File "tkinter/__init__.pyc", line 1277, in mainloop
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Fatal Python error: PyEval_RestoreThread: NULL tstate
Current thread 0x00007fffa118e380 (most recent call first):
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...none found.
[Process completed]
I have been using Python 3.6 and Py2App v0.13 because it is, unfortunately, the only version that has successfully packaged my program in a standalone package. Any version later than 0.13 gives me the following error even when bundling in alias mode:
Traceback (most recent call last):
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 420, in <module>
_run()
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 414, in _run
exec(compile(source, script, 'exec'), globals(), globals())
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/riffgen_v1.01.py", line 7, in <module>
from tkinter import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ValueError: character U+6573552f is not in range [U+0000; U+10ffff]
I've seen a handful of people with similar errors to the one above, but the few solutions I've seen had no success.
I'm assuming there is a simple solution to both of these errors, but after a long two weeks of tinkering, I'm out of ideas. I just began programming and really want to continue to deploy GUI programs, so I am desperate to get this functional. Any help is greatly appreciated!!
Probably not an answer you were hoping for, but this might give you some ideas where to look:
check if you don't have multiple pythons installed. Make sure you run it with 3.6. (but you probably already did)
Check the modules installed on both PC's help('modules') in a python shell.
Check if the correct version of the modules is installed. Install the exact same versions pip install SomePackage==1.0.4
Symbol not found: ____chkstk_darwin seems to be a very mac related issue. I'd start searching there in combination with the modules you use in your script. This is the only post I found on stackoverflow and it suggests looking at the PATH settings; plaidml-setup uses the wrong lib path and gets OSErrors
all of a sudden when running PyCharm Community edition i've started to get this syntax error when running debug mode. I tried reinstalling PyCharm but had no luck with the error. Anyone see this before?
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 26, in <module>
from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_additional_thread_info.py", line 19, in <module>
from _pydevd_bundle.pydevd_additional_thread_info_regular import PyDBAdditionalThreadInfo # #UnusedImport
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_additional_thread_info_regular.py", line 5, in <module>
from _pydevd_bundle.pydevd_frame import PyDBFrame
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_frame.py", line 10, in <module>
from _pydevd_bundle.pydevd_breakpoints import get_exception_breakpoint
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_breakpoints.py", line 15, in <module>
from _pydevd_bundle.pydevd_comm import get_global_debugger
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 75, in <module>
import pydevconsole
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevconsole.py", line 10, in <module>
from _pydevd_bundle.pydevconsole_code_for_ironpython import InteractiveConsole
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevconsole_code_for_ironpython.py", line 105
except SyntaxError, err:
^
SyntaxError: invalid syntax
If you don't care about any project specific configurations or run configurations:
quit pycharm
delete .idea folder in your project folder
start pycharm
I've used this method as a quick fix solution when I encountered this issue late last night. But, the very nature of this solution indicates that this issue is caused by some corruption in the .idea folder. Were I to encounter this problem again, I would suggest a different approach:
first, try to search for the error text in the files in the .idea folder
if the previous step fails:
quit pycharm
move the .idea folder inside the project folder to a safe location
start pycharm to create a fresh .idea folder and quit it again
preform a 3-way merge between the old and the new .idea folders
start pycharm
If you have __init__.py in your current path, delete it.
Or if your file name is code.py, rename to something else.
Im trying to figured out this problem. Yesterday I installed PyScripter and since then, scripts doesnt work. When I run any script (in PyScripter or IDLE) and trying to "import arcpy", it gets this error:
import arcpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import arcpy
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
from geoprocessing import gp
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
File "C:\Python26\ArcGIS10.0\lib\arcgisscripting.py", line 81, in <module>
from RuntimeError import RuntimeError
ImportError: No module named RuntimeError
Have somebody any suggestion how to fix it?
Thanks to all very much!
Sounds like the module is not installed properly (or at all). To verify, do the following:
open a shell and start the python shell by typing python
(If this doesn't display an error, check that python is added to your system path or if it is even installed at all. But if you've used Python on said machine maybe system path issue)
enter the commmand help('modules')
review the list of modules that's returned to see whether arcpy is included
if not, then you may have to reinstall the module
I have created a simple program which uses pywin32. I want to deploy it as an executable, so I py2exe'd it. I also didn't want a huge amount of files, so I set bundle_files to 1 (meaning bundle everything together). However, when I attempt running it, I get:
Traceback (most recent call last):
File "pshelper.py", line 4, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "win32.pyc", line 8, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32ui.pyd
In my setup script, I tried doing packages=["win32ui"] and includes=["win32ui"] as options, but that didn't help. How can I get py2exe to include win32ui.pyd?
I don't have this problem if I don't ask it to bundle the files, so I can do that, for now, but I'd like to know how to get it to work properly.
Are you sure that the problem is that win32ui.pyd is not included? The stack trace isn't exactly the same as noted in the wiki, but check this out: http://www.py2exe.org/index.cgi/Py2exeAndWin32ui.
The work-around that has worked best so far is to simply re-implement the pywin32 functions using ctypes. That doesn't require another .pyd or .dll file so the issue is obviated.
Do care to try out PyInstaller? I've used it both on Windows 7 and Ubuntu 10.04 and it worked like magic, even when I compiled to .pyd on Windows.
I've been able to bundle all sorts of applications that I've developed with it.
I have the same problem trying to bundle psutil with py2exe. Here is what I found so far.
Traceback (most recent call last):
File "wx_gui.py", line 43, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "psutil\__init__.pyc", line 85, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "psutil\_psmswindows.pyc", line 15, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading _psutil_mswindows.pyd
I get this traceback when bundle_files = 3. zipfile may be specified or may be None, I still get the problem.
First, I thought this was a missing dll because of this page:
http://www.py2exe.org/index.cgi/ProblemsToBeFixed
I've copied all the dlls I found in Python27 into the same directory as the executable and added that directory path to os.environ['path']. That didn't worked.
Then I tried to import my package directly from site-packages.
I've replaced the whole sys.path of my compiled executable with my normal sys.path
sys.path = [r'C:\Python27\Lib\idlelib', ...]
I think the .pyd module got imported but Visual c++ threw me this really ugly error message:
Runtime Error!
Program: {path}.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I suggest you try to replace the whole sys.path to see if it is working. If it is, you could always make your single executable write the necessary module into a temp directory and add it to your path. If not, I feel like this problem is going to be hard to solve.