pysqlcipher installation on ubuntu with Python 3.4 - syntaxerror - python

I'm following this tutorial to install pysqlcipher, but get a syntax error.
I'm working on Ubuntu 14.04 LTS. I have created a virtual environment with "virtualenv" to use Python 3.4. Despite the tutorial (of the link above), I cannot success to install sqlcipher! The installation crashes when I run this:
python setup.py build_sqlcipher
The error message is this one:
File "setup.py", line 64
print "CFLAGS", os.environ['CFLAGS']
^
SyntaxError: invalid syntax

The project only works on Python 2; it is not compatible with Python 3.
This specific error shows the project is using the Python 2 print statement, which was removed from the language in version 3. It was replaced by a function to do printing instead.
In all likelihood, fixing this one line is not going to be enough. You'll have to ask the project maintainers if they have any plans in supporting Python 3. I see the project already has a ticket open asking for support, it looks like the project is already working on supporting this, but it is not ready at this point in time.
Instead, install Python 2.7 on your Ubuntu machine and run the code with that version.

Related

How to detect whether a third-party python package is available on a fixed python version like python3.4

I am embedding python code in my cpp application to provide python-code-runner service. Recently I encountered a problem when I really need to downgrade my python version from 3.8.10 to 3.4.4, so that my application can fit on windows xp.
I used to provided some automatically-installed python 3rd-party packages for my customers to use. Now, as the downgrade of python version, I have to downgrade the 3rd-party packages' version to let my app function fine.
The problem is that I have no idea how to determine whether a 3rd-party package is suitable for python3.4. Is there a way I can test it?
I searched for pypi to get a version suitable for python3.4, but it turns out that this does not work well, as some 3rd-party-libs may rely on other packages with a semanticVersion mark >=.
Take astroid==1.3.8 for an example. I googled and found this version satisfies 3.4.4, so I installed it, and found syntax error when I use import astroid in my python script. The error indicates a syntax error in the lib logilab-common.
File "C:\Python34\lib\site-packages\astroid\__init__.py",line 54, in <module>
from astroid.nodes import *
...... // some traceback
......
File "C:\Python34\lib\site-packages\logilab\common\deprecated.py", line 105
self._proxied: Any = proxied
^
SyntaxError: invalid syntax
It turns out that the package astroid requires logilab-common>=0.63.0, and when I use pip install astroid==1.3.8, it installed the latest logilab-common, which is 1.9.7, and it used a type annotation, which caused this syntax error.
I managed to install logilab-common==0.63.0, and it worked fine when I use import astroid.
Does that mean I can use astroid all fine in python 3.4.4? I am not quite sure whether other functions or apis in this package will raise some syntax error or crash unexpectedly. Is there a way I can test it?
In the case, always installing the minium-satisfied-version of dependency-libs definitely works fine, but that's too much work for me. I want to find a way to test the utility of the libs and their dependency-libs.

Why is my python module not importing ON linux

As you can see I have imported the modules correctly using pip install. I googled a bit why the module was not imported and I realized I have to add it to PATH. I did that too but now there is a new error something about a syntax error
File "pygame/__init__.py",
self.reason = f"{exc_type.__name__}: {self.info}"
Is this because my chrome book can not run Pygame or is the problem something else?
Picture of my terminal with the error:
you need to run python3. to start python 3. Just running python starts python 2.7.
you have your installed packages in python 3.9 version while your python environment is 2.7, look for python3 executable and try with that version

Using Flask and Jython under Windows 7

Hello everyone,
So I have been trying to use Jython to connect to an API Rest and retrieve some information. Now I want to use the Flask Framework with it. I have been trying to install the Flask with Jython but it does not seem to work at all. I am working on a Windows 7 machine and the problem for me is also that I can not download directly from the internet. For all other framework I used python wheels and installed these with Jython which worked fine.
I already tried to following commands and got these errors:
First error that I got was that it could not find the 'init.py' file in the flask folder so I changed the path in the file to the total path. But it just continued to give me more errors.
jython -m pip install '*.whl
Screenshot of the command line ouput of the error
pip install '*.whl (same as above)
I am a little stuck here and I hope that someone has an idea on how to solve this problem.
Big thanks already!!
This appears to be a bug with Jython 2.7.0. See this error report in pip and this one in Jython.
The second of those indicates that it is fixed in the 2.7.1 release candidate.

Python 2.4 - Installing Modules Syntax Error

I'm currently teaching myself Python and am working my way through automatetheboringstuff.com. I'm having trouble installing third party modules in Python 2.4 (this is the newest version I have available to me at work). For instance, when I try to install the requests module so I can work with web pages, I get an invalid syntax error. Here's the procedure I'm using:
Open command line and cd to the folder where the setup.py file for the module is
Type into the command line: setup.py install
Then I get the following error:
File "C:\Users\Username\Desktop\PyRequestsModule\setup.py", line 52
with open('requests/_init__py', 'r') as fd:
^
syntaxError: invalid syntax
I get a similar error every time I try to install a module. Is the issue that I'm running Python 2.4 or am I doing something wrong?
Please do not learn Python 2, if you do not have to use this version for legacy reasons. Its support will end 2020 and most libraries are available for Python 3 too. Some even only for Python 3.
If you can't install a newer version, you can try to use a portable one.

Python IDLE wont' start (Mac) - Problems from a Python/Unix newbie

Months ago, I installed Python 2.7 on my MacBook Pro (OS 10.8.5) and was using IDLE to run programs for classes I was taking on Udacity. One morning IDLE would no longer start, it would just bounce around on the dock and then close. I was eventually able to get things working again by installing Python 3.3 and using that IDLE.
A few days ago, I tried to get 2.7 working again by uninstalling all versions of Python and reinstalling using Macports. (To uninstall, I simply deleted the Python folders in my application folder, the Python.framework file in /Library/Frameworks and some symlinks in /usr/local/bin. Got the idea from another post here: How to uninstall Python 2.7 on a Mac OS X 10.6.4?)
Now no version of Python is working for me. When I try to start IDLE, I get the following error message in the Console:
2/7/14 10:28:02.556 PM com.apple.launchd.peruser.502[151]: ([0x0-0xc80c8].org.python.IDLE[819]) Exited with code: 1
The Python in the terminal still works, by the way. I also tried installing another IDE, PyCharm, but that doesn't work either (I get a message saying No Python interpreter selected)
If you are using a MacPorts Python, you will need to install the corresponding py*-tkinter port to use any Tkinter-based Python app, including IDLE. Try:
sudo port install py27-tkinter

Categories