I'm trying to embed ipython into blender. Blender is packaged with its own python, so to get access to all of my own libraries I copy the list from my ipython3 sys.path variable and do:
import sys
for p in
sys.path.append(p)
import IPython
IPython embed
I get the following error:
>>> import IPython
>>> IPython.embed()
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/usr/lib/python3/dist-packages/IPython/frontend/terminal/embed.py", line 282, in embed
_embedded_shell = InteractiveShellEmbed(**kwargs)
File "/usr/lib/python3/dist-packages/IPython/frontend/terminal/embed.py", line 97, in __init__
display_banner=display_banner
File "/usr/lib/python3/dist-packages/IPython/frontend/terminal/interactiveshell.py", line 360, in __init__
user_module=user_module, custom_exceptions=custom_exceptions
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 455, in __init__
self.init_readline()
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 1844, in init_readline
self.refill_readline_hist()
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 1853, in refill_readline_hist
stdin_encoding = sys.stdin.encoding or "utf-8"
AttributeError: 'NoneType' object has no attribute 'encoding'
Any ideas how I can get it to work?
Related
I'm following along with this video:
https://www.youtube.com/watch?v=y8Thrrw25rQ&list=PLmnzWPUjpmaGzFNq2PeMljHNrXGwj2TDY&index=1
trying to set up my dev environment for chialisp.
Installed python, created virtual environment, ran pip install chia-dev-tools (got this working after installing c++ buildtools). All looks to work fine but when i run the chia --help command I'm getting errors
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\chialisp\chiatest1\venv\Scripts\chia.exe_main.py", line 4, in
File "C:\chialisp\chiatest1\venv\Lib\site-packages\chia\cmds\chia.py", line 18, in
from chia.cmds.peer import peer_cmd
File "C:\chialisp\chiatest1\venv\Lib\site-packages\chia\cmds\peer.py", line 7, in
from chia.cmds.cmds_util import NODE_TYPES
File "C:\chialisp\chiatest1\venv\Lib\site-packages\chia\cmds\cmds_util.py", line 17, in
from chia.rpc.wallet_rpc_client import WalletRpcClient
File "C:\chialisp\chiatest1\venv\Lib\site-packages\chia\rpc\wallet_rpc_client.py", line 3, in
from chia.data_layer.data_layer_wallet import Mirror, SingletonRecord
File "C:\chialisp\chiatest1\venv\Lib\site-packages\chia\data_layer\data_layer_wallet.py", line 42, in
from chia.wallet.outer_puzzles import AssetType
File "C:\chialisp\chiatest1\venv\Lib\site-packages\chia\wallet\outer_puzzles.py", line 8, in
from chia.wallet.cat_wallet.cat_outer_puzzle import CATOuterPuzzle
File "C:\chialisp\chiatest1\venv\Lib\site-packages\chia\wallet\cat_wallet\cat_outer_puzzle.py", line 11, in
from chia.wallet.cat_wallet.cat_utils import (
File "C:\chialisp\chiatest1\venv\Lib\site-packages\chia\wallet\cat_wallet\cat_utils.py", line 24, in
#dataclasses.dataclass
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tony\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1220, in dataclass
return wrap(cls)
^^^^^^^^^
File "C:\Users\tony\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1210, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tony\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 958, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tony\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 815, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'chia.types.blockchain_format.program.Program'> for field limitations_solution is not allowed: use default_factory
Any thoughts on where I might be going wrong??
For future reference I had to run this command
Set-Alias -Name chia "C:\Users[insert user here]\AppData\Local\Programs\Chia\resources\app.asar.unpacked\daemon\chia.exe"
This is all my code
import pyglet
import ratcave as rc
window = pyglet.window.Window()
pyglet.app.run()
When running this, the following shows in terminal
Traceback (most recent call last):
File "c:\CODING\pyopengl\Mudge-David-Homework-8.py", line 14, in <module>
import ratcave as rc
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\__init__.py", line 5, in <module>
from . import resources
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\resources.py", line 40, in <module>
default_camera = Camera()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 260, in __init__
self.projection = PerspectiveProjection() if not projection else projection
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\utils\observers.py", line 56, in __setattr__
super(AutoRegisterObserver, self).__setattr__(key, value)
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 299, in projection
self.reset_uniforms()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 302, in reset_uniforms
self.uniforms['projection_matrix'] = self.projection_matrix.view()
PS C:\Users\David> & C:/Users/David/AppData/Local/Microsoft/WindowsApps/python3.10.exe c:/CODING/pyopengl/Mudge-David-Homework-8.py
Traceback (most recent call last):
File "c:\CODING\pyopengl\Mudge-David-Homework-8.py", line 14, in <module>
import ratcave as rc
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\__init__.py", line 5, in <module>
from . import resources
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\resources.py", line 40, in <module>
default_camera = Camera()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 260, in __init__
self.projection = PerspectiveProjection() if not projection else projection
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\utils\observers.py", line 56, in __setattr__
super(AutoRegisterObserver, self).__setattr__(key, value)
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 299, in projection
self.reset_uniforms()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\camera.py", line 302, in reset_uniforms
self.uniforms['projection_matrix'] = self.projection_matrix.view()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\shader.py", line 139, in uniforms
self.update()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\utils\observers.py", line 47, in update
self.on_change()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\physical.py", line 186, in on_change
Physical.on_change(self)
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\physical.py", line 138, in on_change
self.model_matrix = np.dot(self.position.to_matrix(), self.rotation.to_matrix())
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\coordinates.py", line 126, in to_matrix
return self.to_radians().to_matrix()
File "C:\Users\David\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ratcave\coordinates.py", line 95, in to_matrix
mat[:3, :3] = R.from_euler(self.axes[1:],self._array,degrees=False).as_dcm() # scipy as_matrix() not available
AttributeError: 'scipy.spatial.transform._rotation.Rotation' object has no attribute 'as_dcm'
With seemingly the error being that final line
AttributeError: 'scipy.spatial.transform._rotation.Rotation' object has no attribute 'as_dcm'
Im trying to follow this tutorial
The code should create a new window, which in turn means Pyglet is working.
From what I have researched, this has been solved through SciPy methods being changed, which I have attempted with no luck. Another thread of this issue resolved it by installing the correct version, which would correct these methods. However I have attempted to install different versions of SciPy and still get the same error.
The as_dcm() method of the Rotation class was deprecated in SciPy version 1.4.0 and removed from SciPy version 1.6.0. You'll have to use an older version of SciPy, or find out if there is a version of ratcave that works with the latest version of SciPy.
When I run python on cmd I get this weird error:
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site.py", line 446, in register_readline
import readline
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\readline.py", line 34, in <module>
rl = Readline()
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\rlmain.py", line 422, in __init__
BaseReadline.__init__(self)
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\rlmain.py", line 62, in __init__
mode.init_editing_mode(None)
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\modes\emacs.py", line 633, in init_editing_mode
self._bind_key('space', self.self_insert)
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\modes\basemode.py", line 162, in _bind_key
if not callable(func):
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\py3k_compat.py", line 8, in callable
return isinstance(x, collections.Callable)
AttributeError: module 'collections' has no attribute 'Callable'
But then I continue using python normally:
>>>
I did not find any effects of this problem python is running normally but I do not want it to appear and to know what does it do.
I try to print a ticket in a thermal printer. I use module escpos
but when I run the script in Windows it sends me the following error
Traceback (most recent call last):
File "C:\Users\Angel\Desktop\Escritorio\impreimer.py", line 5, in <module>
Epson = printer.Usb(0x1a86,0x7584,1)
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\escpos\printer.py", line 51, in __init__
self.open()
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\escpos\printer.py", line 68, in open
self.device.detach_kernel_driver(0)
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\usb\core.py", line 1077, in detach_kernel_driver
interface)
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\usb\backend\libusb0.py", line 606, in detach_kernel_driver
_check(_lib.usb_detach_kernel_driver_np(dev_handle, intf))
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'usb_detach_kernel_driver_np' not found
[Finished in 0.5s with exit code 1]
and this is my code:
import sys
from escpos import *
pr = printer.Usb(0x1a86,0x7584)
How can i fix this?
try this.
pr = printer.Usb(0x1a86,0x7584, interface=0, in_ep=0x82, out_ep=0x02)
if you are using Windows you need use programs like zadig or LibusbK and install filters.
https://zadig.akeo.ie/
http://libusbk.sourceforge.net/UsbK3/index.html
Does anyone have any experience using Python with AutoCAD? I'm just trying, as a test to see if I can open a new instance of AutoCAD via Python and though that PyAutocad worked well (feel free to offer other suggestions, if you have any).
Anyway based on the doc (https://pypi.python.org/pypi/pyautocad/#downloads) - it says these lines of code should do it, but nothing's happened as of yet.
from pyautocad import Autocad, APoint
acad = Autocad()
acad.prompt("Hello, Autocad from Python\n")
Just these lines of code should generate info on the commandline but instead results in about 50 lines worth of traceback (which I can post as well if anyone's interested) - any ideas?
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
acad.prompt("Hello, Autocad")
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 153, in prompt
self.doc.Utility.Prompt(u"%s\n" % text)
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 65, in doc
return self.app.ActiveDocument
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 54, in app
self._app = comtypes.client.GetActiveObject('AutoCAD.Application')
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 180, in GetActiveObject
obj = comtypes.GetActiveObject(clsid, interface=interface)
File "C:\Python27\lib\site-packages\comtypes\__init__.py", line 1165, in GetActiveObject
oledll.oleaut32.GetActiveObject(byref(clsid), None, byref(p))
File "_ctypes/callproc.c", line 941, in GetResult
WindowsError: [Error -2147221021] Operation unavailable
After adding the VBA Module, the traceback now reads:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
acad.prompt("Hello")
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 153, in prompt
self.doc.Utility.Prompt(u"%s\n" % text)
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 65, in doc
return self.app.ActiveDocument
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 54, in app
self._app = comtypes.client.GetActiveObject('AutoCAD.Application')
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 183, in GetActiveObject
return _manage(obj, clsid, interface=interface)
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 112, in GetBestInterface
interface = getattr(mod, itf_name)
AttributeError: 'module' object has no attribute 'IAcadApplication'
Now after deleting comtypes' "gen" folder per #reclosedev, Autocad now opens but the string of text still will not appear on the command line - the traceback reads:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
acad.prompt("Hello")
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 153, in prompt
self.doc.Utility.Prompt(u"%s\n" % text)
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 65, in doc
return self.app.ActiveDocument
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 59, in app
self._app.Visible = self._visible
File "C:\Python27\lib\site-packages\comtypes\client\dynamic.py", line 116, in __setattr__
dispid = self._comobj.GetIDsOfNames(name)[0]
File "C:\Python27\lib\site-packages\comtypes\automation.py", line 643, in GetIDsOfNames
self.__com_GetIDsOfNames(riid_null, arr, len(names), lcid, ids)
COMError: (-2147418111, 'Call was rejected by callee.', (None, None, None, 0, None))
Have you considered IronPython?
http://through-the-interface.typepad.com/through_the_interface/2009/03/using-ironpython-with-autocad.html
Here's a quick example of how it could be leveraged:
import clr
import System
from System import Type, Activator
acApp = Activator.CreateInstance(Type.GetTypeFromProgID("AutoCAD.Application"))
acApp.Visible = 1
acApp.ActiveDocument.SendCommand("(Princ \"Hello World from Python!\")(Princ)\n")
Obviously the ProgId will correspond to whichever version of AutoCAD was opened last.