Python – Module Not Found

All modules in Python have to have a certain directory structure. You can find details here. Create an empty file called __init__.py under the model directory, such that your directory structure would look something like that: Also in your hello-world.py file change the import statement to the following: That should fix it P.S.: If you are placing your model directory in some other location … Read more

Best way to replace multiple characters in a string?

Replacing two characters I timed all the methods in the current answers along with one extra. With an input string of abc&def#ghi and replacing & -> \& and # -> \#, the fastest way was to chain together the replacements like this: text.replace(‘&’, ‘\&’).replace(‘#’, ‘\#’). Timings for each function: a) 1000000 loops, best of 3: 1.47 μs per … Read more

pg_config executable not found

I am having trouble installing psycopg2. I get the following error when I try to pip install psycopg2: But the problem is pg_config is actually in my PATH; it runs without any problem: I tried adding the pg_config path to the setup.cfg file and building it using the source files I downloaded from their website (http://initd.org/psycopg/) and I get the following … Read more

AttributeError: Module Pip has no attribute ‘main’

I am trying to build the python api for an open source project called Zulip and I keep running into the same issue as indicated by the screenshot below. I am running python3 and my pip version is 10.0.0. The file in question is setup.py and the code that is messing up is when the pip.main() attribute is accessed … Read more