I am trying to run PyCallgraph module on my application. My application runs on Mac and I am running the application from PyCharm
Here is what I have tried
def main(url):
from pycallgraph import PyCallGraph
from pycallgraph.output import GephiOutput, GraphvizOutput
graphviz = GraphvizOutput()
with PyCallGraph(output=graphviz):
obj = MyApp("agr1")
obj.extract('372','100001' , '999')
I am getting the following error ...
libpath/shortest.c:324: triangulation failed
libpath/shortest.c:192: source point not in any triangle
Error: in routesplines, Pshortestpath failed
Traceback (most recent call last):
File "/Users/anurag/Work/quad-projects/quad-hge/src/main/python/extractor/hgextractor.py", line 63, in <module>
main(url)
File "/Users/anurag/Work/quad-projects/quad-hge/src/main/python/extractor/hgextractor.py", line 51, in main
hge.extract('372','100001' , '999', url_list)
File "/Users/anurag/.virtualenvs/robot/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 38, in __exit__
self.done()
File "/Users/anurag/.virtualenvs/robot/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 81, in done
self.stop()
File "/Users/anurag/.virtualenvs/robot/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 90, in generate
output.done()
File "/Users/anurag/.virtualenvs/robot/lib/python2.7/site-packages/pycallgraph/output/graphviz.py", line 112, in done
'code %(ret)i.' % locals())
pycallgraph.exceptions.PyCallGraphException: The command "dot -Tpng -opycallgraph.png /var/folders/00/z1t7sw2x1ml1ydhgp084c1xh0000gn/T/tmphl_rNH" failed with error code 11.
Process finished with exit code 1
I even tried installing graphviz on my Mac using brew install graphviz
and setting $PATH variable on my PyCharm editor as described here pycallgraph with pycharm does not work
I don't know the exact root cause for this and I am stuck at this for last 2-3 days.
Related
I'm kind of new in the programming world, and I've heard that pypy3 is 7x faster than python while running code, so I decided to give it a try. I created a bot to farm EXP on the game Yu-Gi-OH! duel links and wanted to run it with pypy3, however I need to install opencv and every time I try to do so I get this error .
commands I ran:
git clone https://github.com/skvark/opencv-python
cd opencv-python
pypy3 setup.py install
Error I got:
Traceback (most recent call last):
File "setup.py", line 457, in <module>
main()
File "setup.py", line 257, in main
cmake_source_dir=cmake_source_dir,
File "C:\Users\Jorge\AppData\Local\pypy3.6-v7.3.3-win32\site packages\skbuild\setuptools_wrap.py", line 625, in setup
cmake_source_dir, skbuild_kw['cmake_install_dir'])
File "setup.py", line 370, in _classify_installed_files_override
raise Exception("Not found: '%s'" % relpath_re)
Exception: Not found: 'python/cv2[^/]*\.pyd'
obs: I'm using windows
Can anyone help me?
I have Python 2 and Python 3 installed on my system.
I run the following script:
#!/usr/bin/env python
import nxt.locator
from nxt.motor import *
def spin_around(b):
m_left = Motor(b, PORT_B)
m_left.turn(100, 360)
m_right = Motor(b, PORT_C)
m_right.turn(-100, 360)
b = nxt.locator.find_one_brick()
spin_around(b)
with the command: python spin.py which uses Python 2, as expected.
However, when I run this command I get the following error:
Traceback (most recent call last):
File "spin.py", line 12, in <module>
b = nxt.locator.find_one_brick()
File "/Library/Python/2.7/site-packages/nxt/locator.py", line 112, in find_one_brick
for s in find_bricks(host, name, silent, method):
File "/Library/Python/2.7/site-packages/nxt/locator.py", line 43, in find_bricks
for s in socks:
File "/Library/Python/2.7/site-packages/nxt/usbsock.py", line 84, in find_bricks
for bus in usb.busses():
File "/Library/Python/2.7/site-packages/usb/legacy.py", line 353, in busses
sorted(core.find(find_all=True), key=lambda d: d.bus),
File "/Library/Python/2.7/site-packages/usb/core.py", line 1263, in find
raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available
When I run this script my NXT is plugged into my computer by USB and my NXT is on. Additionally, I have installed pyUSB (correctly, I think).
Why could this error be occurring?
The solution was to install libUSB. It seems the pyUSB library relies on libUSB in the background.
I installed libUSB with brew install libusb
Afterwards, that particular error was fixed.
I'm attempting to install pip for arcpy (arcgis 10.2 on windows 7). Running get-pip.py results in the following error message:
X:\python>python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "c:\temp\tmpou5fje\pip.zip\pip\__init__.py", line 26, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\utils\__init__.py", line 27, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\_vendor\pkg_resources\__init__.py", line 73, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\_vendor\packaging\specifiers.py", line 275, in <module>
File "c:\temp\tmpou5fje\pip.zip\pip\_vendor\packaging\specifiers.py", line 373, in Specifier
File "C:\Python27\ArcGIS10.2\Lib\re.py", line 190, in compile
return _compile(pattern, flags)
File "C:\Python27\ArcGIS10.2\Lib\re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat
Using an administrator command prompt doesn't help. My real goal is to get win32com working under arcpy. I usual just copy the appropriate directories out of c:\python27\lib\site-packages to c:\python27\arcgis10.2\lib\site-packages to install a package under arcpy (why doesn't arcpy come with pip?) but that's not working for win32com, presumably do to a missing dll or other windows specific file.
I would recommend the following:
Get the setuptools module
Get the pip module`
And then run the following in command line (assuming windows)
path-to-python path-to-setuptools install
path-to-python path-to-pip install
I work on a closed network (away from the interwebs of old) and cannot use get-pip.py so I find it best to simply download the actual modules and hard install.
Keep us posted!
Copy get_pip.py to "C:\Python27\ArcGIS10.2", then perform command "python get-pip.py" in the directory.
Note that keep network connected in the process, so that auto-download and setup setuptools,wheels,etc.
Hope that can help you.
Try opening a CMD prompt and typing:
C:\Python27\ArcGIS10.2\python.exe -m pip install -U pip
I have python 3.2 on my pc and i want to be able to run the following:
'pip install requests' and 'pip install selenium'.
To do this i know i need to install pip from here -> https://pip.pypa.io/en/stable/installing/
But when I click on the file python comes up and closes again right away and pip is not installed.
I tried running it through IDLE and get the following:
> Traceback (most recent call last):
File "C:\Users\Jarratt\Desktop\get-pip.py", line 17759, in <module>
main()
File "C:\Users\Jarratt\Desktop\get-pip.py", line 162, in main
bootstrap(tmpdir=tmpdir)
File "C:\Users\Jarratt\Desktop\get-pip.py", line 110, in bootstrap
import setuptools # noqa
File "C:\Python32\lib\site-packages\setuptools-19.2-py3.2.egg\setuptools\__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "C:\Python32\lib\site-packages\setuptools-19.2-py3.2.egg\setuptools\extension.py", line 8, in <module>
File "C:\Python32\lib\site-packages\setuptools-19.2-py3.2.egg\setuptools\dist.py", line 19, in <module>
File "C:\Python32\lib\site-packages\setuptools-19.2-py3.2.egg\pkg_resources\__init__.py", line 106, in <module>
warnings.warn(msg)
File "C:\Python32\lib\idlelib\PyShell.py", line 59, in idle_showwarning
file.write(warnings.formatwarning(message, category, filename,
AttributeError: 'NoneType' object has no attribute 'write'
>>>
You need to run it from the command line:
Download https://bootstrap.pypa.io/get-pip.py save somewhere so that you could find it like "C:\".
Open "Start Menu" and in execute type "cmd" and [Enter], or search for "Standard" folder in "Start Menu" and open "Command line" there.
In command line type and execute "python C:\get-pip.py" or "python3 C:\get-pip.py".
Usually works fine this way.
Looks like you are new to python, But pip.exe is a command
and you have to run it from command line, or with run, or by manually clicking on it's icon. You can use this code if you want to:
>>> import os
>>> os.system("pip")
I've been having a real issue trying to make Rpy2 play nice with my R install. I first tried installing the rpy2 MSI package, and this didn't appear to work. When I ran the recommended tests, it was giving me an error saying that it couldn't find the R.dll, because the new R installs (post 2.11) install the DLLs into an i386 folder, where rpy2 can't find them because its looking in the bin folder instead of the bin/i386 folder.
Then I tried to build the install from scratch myself using the command line tools (distutils) included with python. This didn't work, because setup.py claimed to be unable to find the R_home location. But I did work out that editing an environment variable (PATH) might show the rpy2 setup where to find the R installation. I then made a couple of edits to the environment, adding the "R_home" variable pointing to the bin/i386 directory, and made a new entry under the PATH variable, pointing to the same spot.
Unfortunately, when it found the R path, I got this issue instead:
running build
running build_py
running build_ext
Traceback (most recent call last):
File "setup.py", line 372, in <module>
[os.path.join('doc', 'source', 'rpy2_logo.png')])]
File "C:\Python26\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
self.run_command(cmd)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\lib\distutils\command\build.py", line 134, in run
self.run_command(cmd_name)
File "C:\Python26\lib\distutils\cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "C:\Python26\lib\distutils\dist.py", line 994, in run_command
cmd_obj.ensure_finalized()
File "C:\Python26\lib\distutils\cmd.py", line 117, in ensure_finalized
self.finalize_options()
File "setup.py", line 111, in finalize_options
config += get_rconfig(r_home, about)
File "setup.py", line 264, in get_rconfig
rc = RConfig.from_string(rconfig)
File "setup.py", line 252, in from_string
+ '\nin string\n' + string)
ValueError: Invalid substring in string
So I went back to trying to use the premade install, thinking that maybe the new edits to the environment might work but got this issue here
Traceback (most recent call last):
File "<string>", line 245, in run_nodebug
File "C:\Documents and Settings\User\Desktop\rpy2-2.1.9\rpy\tests.py", line 3, in <module>
import rpy2.robjects.tests
File "C:\Python26\lib\site-packages\rpy2\robjects\__init__.py", line 12, in <module>
import rpy2.rinterface as rinterface
File "C:\Python26\lib\site-packages\rpy2\rinterface\__init__.py", line 56, in <module>
raise RuntimeError("Unable to locate R.dll within %s" % R_HOME)
RuntimeError: Unable to locate R.dll within C:\Program Files\R\R-2.12.1\bin\i386
This is REALLY weird, because (as anyone can check on their own install) R installs R.dll into "C:\Program Files\R\R-2.12.1\bin\i386" and I've checked and verified that its in there, and I've pointed rpy2 to this directory in the windows default PATH! I know for a fact that rpy2 is looking in the right place, but can't understand why its not seeing R.dll.
So why can't rpy2 find it? And does anyone know a way to get rpy2 working with R 2.12? Perhaps I should try the newer rpy2 2.2.0 version? Its still in development though, and 1.9 is supposed to be able to handle R 2.12 according to this website so I don't know what to do...
Thanks to anyone who can help out...
[EDIT] I've also tried these instructions over here but they return the same "can't find DLL" error... Unless you change the environment variable "R_home" to point straight at the c/program files/R/R 2.12 directory instead of into the i386 subdirectory.
If it points at the right place, you get these errors back. This looks a bit more promising... But its still pretty bad!
.......................F....................................F.FFF...F....................................................................F..................................
======================================================================
FAIL: testNewWithoutInit (rpy2.rinterface.tests.test_SexpVector.SexpVectorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\rpy2\rinterface\tests\test_SexpVector.py", line 43, in testNewWithoutInit
self.assertTrue(False) # worked when tested, but calling endEmbeddedR causes trouble
AssertionError
======================================================================
FAIL: testCallErrorWhenEndedR (rpy2.rinterface.tests.test_EmbeddedR.EmbeddedRTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\rpy2\rinterface\tests\test_EmbeddedR.py", line 122, in testCallErrorWhenEndedR
self.assertTrue(False) # worked when tested, but calling endEmbeddedR causes trouble
AssertionError
======================================================================
FAIL: testReadConsoleWithError (rpy2.rinterface.tests.test_EmbeddedR.EmbeddedRTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\rpy2\rinterface\tests\test_EmbeddedR.py", line 117, in testReadConsoleWithError
self.assertTrue(errorstring.startswith('Traceback'))
AssertionError
======================================================================
FAIL: testSetReadConsole (rpy2.rinterface.tests.test_EmbeddedR.EmbeddedRTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\rpy2\rinterface\tests\test_EmbeddedR.py", line 97, in testSetReadConsole
self.assertEquals(yes.strip(), res[0])
AssertionError: 'yes' != ''
======================================================================
FAIL: testSetWriteConsole (rpy2.rinterface.tests.test_EmbeddedR.EmbeddedRTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\rpy2\rinterface\tests\test_EmbeddedR.py", line 36, in testSetWriteConsole
self.assertEquals('[1] "3"\n', str.join('', buf))
AssertionError: '[1] "3"\n' != ''
======================================================================
FAIL: testWriteConsoleWithError (rpy2.rinterface.tests.test_EmbeddedR.EmbeddedRTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\rpy2\rinterface\tests\test_EmbeddedR.py", line 55, in testWriteConsoleWithError
self.assertTrue(errorstring.startswith('Traceback'))
AssertionError
======================================================================
FAIL: testVectorUnicodeCharacter (rpy2.robjects.tests.testNumpyConversions.NumpyConversionsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\rpy2\robjects\tests\testNumpyConversions.py", line 54, in testVectorUnicodeCharacter
self.assertTrue(False) # arrays of unicode characters causing segfault
AssertionError
----------------------------------------------------------------------
Ran 172 tests in 0.407s
FAILED (failures=7)
Exit code: True
After many hours of searching on the web and trying out many different things, amongst others encountering the same issues as above, I finally got Rpy2 working on my windows 7 computer!
Basically, the crucial help came from this thread: http://www.mail-archive.com/rpy-list#lists.sourceforge.net/msg03348.html.
Summarized, these were the steps to get rpy2 up and running on Windows7:
Install rpy2 from this link: https://bitbucket.org/breisfeld/rpy2_w32_fix/issue/1/binary-installer-for-win32
Add the path to R.dll to the environment variable PATH (C:\Program Files\R\R-2.12.1\bin\i386 in my case)
Add an environment variable R_HOME (C:\Program Files\R\R-2.12.1 in my case)
Add an environment variable R_USER (simply my username in Windows)
Restart your Python IDE (otherwise the environment variables are not reloaded!)
RPy2 isn't tested on Windows. You can try using an older version (2.0.8) with a Windows installer, but that may have trouble with newer versions of R.
The author doesn't use Windows. If you've got the knowledge to get a newer version working on Windows, I'm sure he'd welcome contributions.
I'm not sure where to write this, as I can't comment (no reputation points), but feel it is useful info on this problem. The reason for the aggravating "Unable to locate R.dll within..." error message, even when you know that R.dll is located exactly where it says, is that the program isn't actually looking in that directory. I think the relevant action happens in rpy2's "init.py" module in these lines:
import win32api
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'bin', _win_bindir)
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'modules', _win_bindir)
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'lib')
# Load the R dll using the explicit path
R_DLL_DIRS = ('bin', 'lib')
# Try dirs from R_DLL_DIRS
for r_dir in R_DLL_DIRS:
Rlib = os.path.join(R_HOME, r_dir, _win_bindir, 'R.dll')
if not os.path.exists(Rlib):
continue
win32api.LoadLibrary( Rlib )
_win_ok = True
break
# Otherwise fail out!
if not _win_ok:
raise RuntimeError("Unable to locate R.dll within %s" % R_HOME)
As you can see, the error message will always say that it is looking in whatever directory you have set as R_HOME, but it will actually be looking in the directory "R_HOME\ r_dir\win_bindir". So when you see a message like "Unable to locate R.dll within C:\Program Files\R\R-2.12.1\bin\i386", that's because it is actually looking for a directory named C:\Program Files\R\R-2.12.1\bin\i386\R-2.12.1\bin\i386\, or something like that.
Point 3 in Kadee's answer fixes this by leaving the path specified only down to immediately above the \bin level.