google / ci_edit

A terminal text editor with mouse support and ctrl+Q to quit.
Apache License 2.0
223 stars 54 forks source link

AttributeError: module 'profile' has no attribute 'run' #192

Closed navan0 closed 5 years ago

navan0 commented 5 years ago

Traceback (most recent call last): File "/usr/local/bin/y", line 35, in import app.ci_program File "/opt/ci_edit/app/ci_program.py", line 24, in import cProfile File "/usr/lib/python3.6/cProfile.py", line 22, in run.doc = _pyprofile.run.doc AttributeError: module 'profile' has no attribute 'run'

dschuyler commented 5 years ago

Thanks for reporting this. I normally test with Python 2.7.10 and 3.7. I downloaded Python 3.6.8 and tried that but didn't see an issue.

Please paste the output from $ python3 --version into this bug so that we can see the specific 3.6 version and which platform this is happening on.

Also, consider trying Python 3.7 to see if the problem happens in that version.

navan0 commented 5 years ago

It's python 3.6.7

gennad commented 5 years ago

Do we need profiling of programs for regular users at all? Maybe add some flag like "--dev" to enable profiling?

dschuyler commented 5 years ago

@gennad, sounds good. I'm a bit concerned that the Python install on @Navan0 's machine is damaged(?). While @gennad is correct about not needing this code, it should still work without crashing afaik.

navan0 commented 5 years ago

hmm i will reinstall and check

billtubbs commented 5 years ago

I thought I had this problem. Then I realised it's because I had created a script called profile.py to run the profile! (This causes AttributeError: module 'cProfile' has no attribute 'run'). Hope that helps!

dschuyler commented 5 years ago

Good to know!

Where was the profile.py created? (Was it in the ci_edit directory - with the ci.py file?)

billtubbs commented 5 years ago

It was in the current working directory - the profile.py script was the script I was actually running which did some setup and called the module which had the function I wanted to profile. Just a classic case of don't give your script the same name as a Python package in your path... Now I renamed it speedtest.py.

dschuyler commented 5 years ago

Thanks again. Since it's been awhile since Navan0's report and the description from billtubbs seems reasonable, I'll close this (assigned to billtubbs to credit billtubbs).

Abhihugar commented 2 years ago

import cProfile to run

Abhihugar commented 2 years ago

it has run attribute

Abhihugar commented 2 years ago

import cProfile import re

for i in range(5): print(pr.calibrate(10000)) a=cProfile.run('re.compile("Hello")') print(a)