I previously had Python 2.7 installed and was making calls like this:
api = jsonrpclib.Server('my host')
api.someFunctionCall()
I then upgraded to Python 3.5.2 and now when I run the code above, I'm receiving this message:
Traceback (most recent call last):
File "C:\login\login.py", line 1, in <module>
import jsonrpclib
File "C:\Python3.5.2\lib\site-packages\jsonrpclib\__init__.py", line 5, in <module>
from jsonrpclib.jsonrpc import Server, MultiCall, Fault
ImportError: No module named 'xmlrpclib'
I checked my installation and I do indeed have the xmlrpc lib:
c:\Python3.5.2\Lib\xmlrpc
What am I doing wrong?
Python 3.x has relocated the xmlrpclib module. Per the Python 2.7 xmlrpclib documentation:
"The xmlrpclib module has been renamed to xmlrpc.client in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3."
It looks like the author of jsonrpclib has an open issue for Python 3 support, but hasn't responded or taken pull requests in a year. You may want to give the jsonrpclib-pelix fork a look for Python 3 support.
Related
I'm trying to use the Python YouTube Data API Python script that allows to upload a video: https://developers.google.com/youtube/v3/guides/uploading_a_video#Sample_Code. Note that it's compatible Python 2.x, not 3.X. So I've updated its code by replacing the first import ( import httplib ) by this import: import http.client .
When I run this script, the following error is shown:
Traceback (most recent call last):
File "/home/xzerzxez/pycharm_projects/zerde/upload_video.py", line 3, in
import http.client
ImportError: No module named http.client
Process finished with exit code 0
PyCharm's used environment: my Ubuntu's one
Python version: /usr/bin/python3.6
Pertinent packages installed: httplib2, request, requests
Available packages to install: micropython-http.client, pycopy-http.client, yieldfrom.http.client
How to solve this problem?
Edit: of course I also made other littles changes to the code to make it compatible Python 3.X, but it's off-topic :-) .
Solved by changing the shebang to #!/usr/bin/python3
I am using and importing ConfigParaser
import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('Config.properties')
timeout_val=config.get('Section', 'commandtimeout')
and install it using,
pip install ConfigParser
While running the python script getting below mention error.
Traceback (most recent call last):
File "system_offline.py", line 41, in <module>
import ConfigParser
ImportError: No module named 'ConfigParser'
Now, my question is if run the same program using python 2.7 at the same system, above import statement works with out issue.
Wondering what needs to be done for this program to run with python3?
Edit: While using python 2.7 it is working but with python3, i am getting above mention error.
The ConfigParser module was renamed to configparser in Python 3.0.
If you are using python 3, this will work, the module was renamed
import configparser
config = configparser.RawConfigParser()
I'm trying to run the hello world tutorial for the Google app engine in Go language. The GAE SDK for go is based on python 2.5, which I installed. I then had to install openssl, but now when I try to run my sample application on the SDK, I get the following error:
ImportError: No module named _md5
I even tried a simple import md5 & import hashlib from the python interpreter interface, and i still get the same error
>>> import hashlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/hashlib.py", line 133, in <module>
md5 = __get_builtin_constructor('md5')
File "/usr/local/lib/python2.5/hashlib.py", line 60, in __get_builtin_constructor
import _md5
ImportError: No module named _md5
Does anybody know a workaround for this? Thank you!
I have a feeling that this problem is really about python installation than anything else
Your problem has nothing to do with GAE, or the SDK. I have faced this before. If you tried to install your custom version of python (on Ubuntu), then you land up with such issues. You should uninstall the custom python using checkinstall. More details can be found about there here: Uninstall python built from source?.
Just use the default python and you'll be fine!
I'm trying to configure and run SVN post-commit hook sending mails. I've downloaded class mailer.py, installed Python 2.7 and svn-win32 bindings for svn. The machine is Windows-7 64 bit, the Python is 32 bit. Now the mailer.py ends with error, which is caused by import problem.
When I in python console type "import svn.core" I have following error:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\tools\Python27\lib\site-packages\svn\core.py", line 19, in <module>
from libsvn.core import *
File "c:\tools\Python27\lib\site-packages\libsvn\core.py", line 5, in <module>
import _core
ImportError: No module named _core
while in directory site-packages/libsvn are files such as: _core.dll
I've installed other bindings, pysvn, that was installed correctly, but as far as I've noticed, it's the totally other API so I can't use that for python.py
Does someone had similar problem and knows how to deal with it?
The Python bindings need to load the native Subversion libraries (DLL's). If your Python is 32-bit then you would need 32-bit versions of the native Subversion libraries on PATH.
I have problem like this. Trouble was that python just can not import this library (svn.core and other).
I just make:
import sys
sys.path.append("C:\csvn\lib\svn-python").
My file core.pyc was in C:\csvn\lib\svn-python\svn. Hope it helps somebody. Such behacior for me is strange because there is no "init.py" or "init.pyc" file in svn-python directory. But it works.
Alright, I have tried a bunch of times the
python setup.py install
command from my command prompt
And when trying this:
from SimPy.Simulation import *
on Idle, I get this:
Traceback (most recent call last):
File "C:/Python30/pruebas/prueba1", line 1, in <module>
from SimPy.Simulation import *
File "C:\Python30\SimPy\Simulation.py", line 320
print 'SimPy.Simulation %s' %__version__,
^
SyntaxError: invalid syntax
>>>
Not every module supports python 3 - in fact, 90% or more of the modules are for 2.x now.
you should use 2.5 or 2.6 for this module, or find a simpy that is compatible with 3.0.
you can also run the 2->3 upgrade script to modify your simpy source, but I don't suggest doing that.
I have a similar error, and I Installed python 2.6.4, so I don't think you can solve your problem using an older version of python.
alumno#ubuntu:/usr/local/SimPy/SimPy$ python carro.py
Traceback (most recent call last):
File "carro.py", line 2, in <module>
from SimPy.Simulation import *
ImportError: No module named SimPy.Simulation
Python 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11)
[GCC 4.4.1] on linux2
Refer point 4 of:
http://pythonhosted.org/SimPy/Manuals/INSTALLATION.html
for a workaround. It worked for me.
simpy package does not seem to have same classes as SimPy by using pip install SimPy command, simpy gets installed.
Hence, just download the SimPy package from the link and copy it to your classpath for python.
There is nothing wrong with your Python installation. SimPy 1 and SimPy 2 use remarkably different syntax from SimPy 3, which is the version that you have installed - and the one which is widely available. The old tutorials are all written in view of the old SimPy versions. Checkout this page...
http://simpy.readthedocs.org/en/latest/simpy_intro/installation.html