Python module httplib2 and python path - python

I am trying to use httplib2 in Python 2.7 on Windows 7 using the IDLE PythonWin 32 build 219.
I downloaded it and installed using python setup.py install method.
On Windows command line the following is successful:
python
import httplib2
httplib2
<module 'httplib2' from 'C:\Python27\ArcGISx6410.2\lib\site-packages\httplib2-0.9.2-py2.7.egg\httplib2\__init__.pyc'>
Here's the problem: in PythonWin importing httplib2 returns:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named httplib2
I added the location of the module returned in command line (above) using sys.path.append in command line hoping that would resolve the issue.
PythonWin still cannot import the module, and sys.path in PythonWin does not return the appended path to httplib2. I appended the path the same way in PythonWin, but still could not import the module, and when I reopened PythonWin, the path did not cotain the appended module anymore.
Why or how could PythonWin be using a different path, and how can I get PythonWin to be able to import httplib2?

Have you tried using the command line tool pip ? You can use it like so:
pip install httplib2
That should put it on your path. If you don't have pip installed see this post. Also, worth mentioning, httplib2 is not as friendly as requests which I personally prefer.

Related

"ModuleNotFoundError : No module named 'apiclient ' "

I recently tried to view Google Calendar using python . To do that I referred Python Quickstart. I did the steps that were mentioned in the website.
I completed the second step and downloaded the secretclient.json file.
In the terminal I typed in :
pip install --upgrade google-api-python-client
as I was instructed in the website.
I ran the python that was on the website and when I compiled I got the error:
Blockquote
Traceback (most recent call last):
File "quickstart.py", line 2, in
from apiclient import discovery
ModuleNotFoundError: No module named 'apiclient'
The Lines which correspond to the error are :
from apiclient import discovery
Why is the apiclient module unavailable ?
Could it be that you're using a different python version than what the pip installed? For example, if you use python3 to execute the problematic import line, but pip is for python2. Or if you use conda or another python distribution that uses a different path to import the packages from.
You can verify it if you just open from the command line:
python
then
from apiclient import discovery
and check if you still get the error.
you can resolve this by going to Script folder of your Python installation directory and running from there
e.g.
cd D:\Python27\Scripts\
python
from apiclient import discovery
Mainly this issue arises when u have more than one python installation , as noob have suggested

How to install M2Crypto for python in Windows x64

I need to use M2Crypto in my python script. I downloaded the M2Crypto windows installer from: https://pypi.python.org/pypi/M2CryptoWin64
When I imported the M2Crypto in my script using: import M2Crypto and run my script, I get errors.
Traceback (most recent call last):
File "C:/Users/xxx/PycharmProjects/TLSscanner/scanner_v2.py", line 4, in <module>
from M2Crypto.Err import SSLError
File "C:\Users\xxx\PycharmProjects\TLSscanner\M2Crypto\__init__.py", line 22, in <module>
import __m2crypto
ImportError: No module named '__m2crypto'
I do not know where to place the M2Crypto folder after I installed it and extracted it? Can you clarify to me where packages need to be placed in order for the script to run?
EDIT:
This is the successful installation path. Shall I put my python script in the same path? The error I get when running my script (in another folder for the project) is shown above.

How do i ensure i can import pythoncom and pywintypes so i can build a COM server in python 3.4?

Im a trying to build a COM server in Python. I have downloaded and installed Pywin32 (I use 32-bit version of Python 3.4.1, so I downloaded and installed pywin32 for this version).
Now, in order to import pythoncom in IDLE, I need to have two .dll files readily accessible:
-pythoncom.dll
-pywintypes.dll
Both .dll files are in the following directory:
C:\Python34\Lib\site-packages\pywin32_system32
When I give the import statement in IDLE, I get the following error:
Traceback (most recent call last):
File "", line 1, in
import pythoncom
File "C:\Python34\lib\site-packages\pythoncom.py", line 2, in
import pywintypes
ImportError: No module named 'pywintypes'
I reinstalled pywin32, but it still doesn't fix it.
I am now trying to add C:\Python34\Lib\site-packages\pywin32_system32 to my PATH directory, but it doesn’t work. I am trying this via:
os.environ["PATH"] += os.pathsep + C:\Python34\Lib\site-packages\pywin32_system32
I then get the following message:
The syntax of the command is incorrect.
What error am I making in the syntax above? How can I fix this (i.e. how can I add C:\Python34\lib\site-packages\pythoncom.py to my PATH environment)?

Python Requests module - Import Error: No module named requests

I'm trying to use the requests module, but I'm having trouble importing it. I'm running Python 3.4.2 (which I checked is officially supported) on Windows 7.
I've tried installing it the following ways, each time with no luck:
Using pip install requests.
Downloading the zipball and installing using setup.py install
Downloading the source code and manually copying the folder to Python34/Lib/site-packages.
In all those cases, I can see that the requests library is in the site-packages folder.
If I run import requests from the python interpreter, it works fine. This works:
$ python
>>> import requests
>>> requests.get("http://127.0.0.1")
<Response [200]>
But this does not work:
import requests
r = get('http://127.0.0.1':5000')
It always results in this error:
Traceback (most recent call last):
File "E:\test.py", line 1, in <module>
import requests
ImportError: No module named requests
I'm completely out of ideas and not sure what else to try!
EDIT
Turns out I was running more than one version of Python. I also had 2.7.7 installed. As was suggested, running import sys; print sys.path returned Python 2.7.7. Uninstalling that old version fixed the problem.
Run with Python 3 from the command line:
python3 script.py

Error during library import in Python (Windows)

I am trying to configure svn hook for email notification using mailer.py script from apache, but it always crash on import of svn libs. I try two ways of installing svn and python. I try to install everything manually using command line and use CollableNet installer that have preinstalled Python and all libs I need but result is the same.
Now I try to import one library from hole package that I need using python in command line and I have such response:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named svn.core
I try to fix it using:
1) import sys; sys.path.append("C:\csvn\lib\svn-python\svn")
and
2) C:\csvn\lib\svn-python\svn>python "\__init__.py" install
But it didn't help.
For now I have no package with setup.py to install it.
I spend a lot of time on this task, and going crazy a little). Please give me any suggestion how to fix it.

Categories

Resources