I'm trying to get the Revit python shell debugger working in my dynamo but I'm running into issues. It seems to run in Revit alright but I cant get the debugger in dynamo to work as shown here.
Also if anyone has any other methods for debugging python code in Revit, feel free to let me know!
Here is the error I'm getting:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File "<string>", line 13, in <module>
File "C:\Users\cmaltez\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\__init__.py", line 36, in <module>
File "C:\Users\cmaltez\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\db\__init__.py", line 19, in <module>
File "C:\Users\cmaltez\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\db\view.py", line 10, in <module>
File "C:\Users\cmaltez\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\db\collector.py", line 35, in <module>
File "C:\Users\cmaltez\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\__init__.py", line 1, in <module>
File "C:\Users\cmaltez\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\forms\__init__.py", line 12, in <module>
File "C:\Users\cmaltez\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\forms\flexform.py", line 6, in <module>
File "C:\Users\cmaltez\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\forms\resources.py", line 41, in <module>
File "C:\Program Files\Autodesk\Revit 2021\AddIns\DynamoForRevit\IronPython.StdLib.2.7.9\wpf.py", line 11, in <module>
ImportError: No module named _wpf
Which is odd because it seems I have the package located in the directory from the install.
This is what my Dynamo looks like. its the getting started file that comes with RPW.
Here is what I've tried so far:
I've added this path to my searching path here: "C:\Program Files (x86)\IronPython 2.7\Platforms\Net40" according to this post.
Here is an image of my searching path:
RPS works in Revit but doesn't work in dynamo for debugging python scripts.
Here are the contents of wpf.py
#-*- coding: ISO-8859-1 -*-
def _():
import sys
if sys.platform == 'cli':
import clr
clr.AddReference('IronPython.Wpf')
_()
del _
from _wpf import *
any and all help would be appreciated!
So after hours of testing different things, I finally tried to just open the wpf.py file and change the line:
from _wpf import *
to
from wpf import *
and I'm now able to access rpw in dynamo.
but I cant get the debugger working in pycharm still.
I also added the paths to the Net40 folder, the unzipped rpw folder that comes in the install, and the location of my iron python folder
Related
I am using Splunk 8+ and Python 3.6. I am trying to run this https://github.com/0x616c6578/TA-geoip2 plugin.
I get this error message when I look into search.log and try to run the Python command in the log by itself:
C:\Users\strozllc>"C:\Program Files\Splunk\bin\Python3.exe" "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\geoip-command.py
Traceback (most recent call last):
File "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\geoip-command.py", line 8, in <module>
from splunklib.searchcommands import \
File "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\..\lib\splunklib\searchcommands\__init__.py", line 145, in <module>
from .environment import *
File "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\..\lib\splunklib\searchcommands\environment.py", line 20, in <module>
from logging.config import fileConfig
File "C:\Program Files\Splunk\Python-3.7\lib\logging\config.py", line 30, in <module>
import logging.handlers
File "C:\Program Files\Splunk\Python-3.7\lib\logging\handlers.py", line 26, in <module>
import logging, socket, os, pickle, struct, time, re
File "C:\Program Files\Splunk\Python-3.7\lib\socket.py", line 49, in <module>
import _socket
ImportError: Module use of python27.dll conflicts with this version of Python
n.
Huh? I looked at line 8 in geocommand.py and it is from
splunklib.searchcommands import \
dispatch, StreamingCommand, Configuration, Option, validators
I look it C:\Program Files\Splunk\bin, and there is indeed a python27.dll. But how is it getting called?
This is a case of Python 3 trying to run Python 2 code. The latest versions of Splunk (you didn't say which one you're using) only support Python 3 so an error will be thrown when an outdated library file is encountered.
I'd suggest filing an issue on GitHub, but the app appears to be abandonware since it hasn't been touched in a year despite having 4 issues.
Consider forking the code and updating it yourself.
UPDATE: if I change the name of the select module (in which the import error occurs) to select1, the problem goes away! WHAT the?
First off: everything works fine when I try to import my package from the command line, or run pytest in the project directory.
But in PyCharm I'm getting the "attempted relative import beyond top-level package" problem when I try to run my tests, and ONLY while in PyCharm. I can't figure out why.
I have even deleted and re-cloned the repository and the problem still occurs.
Here is the link to the problem branch.
And here is the tb:
Testing started at 4:02 PM ...
C:\Users\ricky\AppData\Local\Programs\Python\Python37\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pycharm\_jb_pytest_runner.py" --path C:/Users/ricky/PycharmProjects/candejar/tests
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pycharm\_jb_pytest_runner.py", line 10, in <module>
from pkg_resources import iter_entry_points
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 36, in <module>
import email.parser
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\email\utils.py", line 29, in <module>
import socket
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\socket.py", line 52, in <module>
import os, sys, io, selectors
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\selectors.py", line 12, in <module>
import select
File "C:\Users\ricky\PycharmProjects\candejar\candejar\select.py", line 24, in <module>
from . import exc
ImportError: attempted relative import with no known parent package
Process finished with exit code 1
I'm sure there is something simple going on here but I just can't figure it out. NOTE: I'm using Python 3.7 RC 1.
The sys.path in pycharm and the command line come out to be the same, except pycharm also includes the pycharm project main package directory (which for some reason appears twice).
I was able to solve this by deleting the .idea directory from the cloned repository and re-opening PyCharm. I still don't know what was wrong, but it is fixed now. Very weird.
UPDATE: it has something to do with the following line in the project .iml file in the .idea folder:
<sourceFolder url="file://$MODULE_DIR$/candejar" isTestSource="false" />
Removing that xml code solves the issue. But I do not know why, and I don't know how it got there in the first place (I do not recall messing around with any of my settings prior to this error).
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 get the following error message using Python v2.7.5 and scipy v0.12.0 with py2exe v0.6.9 on a 32 bit machine using 32 bit versions of the packages from Christoph Gohlke. If anyone can provide relevant and useful suggestions I would greatly appreciate it. Here is the error message:
Traceback (most recent call last):
File "MainWindow.py", line 13, in <module>
from svm.svm import SVM
File "svm\svm.pyc", line 4, in <module>
File "sklearn\svm\__init__.pyc", line 13, in <module>
File "sklearn\svm\classes.pyc", line 3, in <module>
File "sklearn\linear_model\__init__.pyc", line 20, in <module>
File "sklearn\linear_model\sgd_fast.pyc", line 12, in <module>
File "sklearn\linear_model\sgd_fast.pyc", line 10, in __load
File "weight_vector.pxd", line 14, in init sklearn.linear_model.sgd_fast
(sklearn\linear_model\sgd_fast.c:13206)
ImportError: No module named weight_vector
This is my setup.py file:
from distutils.core import setup
import py2exe
import sys
sys.path.append('../')
dcm = 'dcm.testDCM'
svm_path = 'svm.svm'
setup(windows=[{"script":"MainWindow.py"}],
options={"py2exe":{
"includes" : ["sip", dcm, svm_path,
'sklearn',
'scipy.sparse.csgraph._validation',
'sklearn.linear_model.sgd_fast.weight_vector']}})
Actually, I have solved the problem in this question scipy with py2exe problesm and solved it using the second answer in that question (the answer), adding the "scipy.sparse.csgraph._validation" in my includes options for the py2exe.
Then I want to do the similar thing for the error "No module named weight_vector", say, adding the "sklearn.linear_model.sgd_fast.weight_vector" in my includes options. However, it didn't work.
I check the directory "sklearn.linear_model.sgd_fast" only to find that the sgd_fast is a ".pyd" file rather than a .py file. Maybe this is why my methods cannot work.
I didn't get any idea about dealing with the pyd file. Have anybody met the similar problems or got any ideas? I really need your help.
After installing Lion, Aptana has stopped working -- I can no longer run any Python code, despite me failing to find any other problems with Python my system. I've tried restoring defaults in Aptana, re-installing and looking for any missing references in Aptana to python components.
Running a simple "hello world" .py script generates a console message:
Traceback (most recent call last):
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/runfiles.py", line 159, in <module>
main()
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/runfiles.py", line 25, in main
import pydev_runfiles
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_runfiles.py", line 5, in <module>
import pydev_runfiles_unittest
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_runfiles_unittest.py", line 6, in <module>
import pydev_runfiles_xml_rpc
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_runfiles_xml_rpc.py", line 1, in <module>
from pydev_imports import xmlrpclib
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_imports.py", line 14, in <module>
from _pydev_SimpleXMLRPCServer import SimpleXMLRPCServer
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/_pydev_SimpleXMLRPCServer.py", line 116, in <module>
import BaseHTTPServer
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py", line 81, in <module>
import mimetools
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/mimetools.py", line 6, in <module>
import tempfile
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/tempfile.py", line 34, in <module>
from random import Random as _Random
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/random.py", line 45, in <module>
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: dlopen(/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so, 2): Symbol not found: __PyLong_AsScaledDouble
Referenced from: /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so
Expected in: flat namespace
in /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so
Have you tried removing your interpreter and adding it again (that way PyDev would update your PYTHONPATH?
It seems like the problem is that the math.so is not compatible with the latest changes in Lion (so, maybe in the update for Lion it got to 2.7 and you're still with 2.6 in the PYTHONPATH configure in Eclipse?)
For me, a better choice would be using an interpreter downloaded from python.org (where you have more control and don't need to rely on what Mac gives you) and configure the python from python.org.
See: http://pydev.org/manual_101_interpreter.html