I am facing Syntax error on Mac python 3.8 from pycrypto, surprisingly its passing on the linux system,
i know the alternative was proposed to remove pycrypto and install pycryptodome but i didnt get why the above is working on linux and not on mac with the same python version ?
Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Crypto.PublicKey.RSA
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/manish/pyvenv/lib/python3.8/site-packages/Crypto/PublicKey/RSA.py", line 585
except ValueError, IndexError:
^
SyntaxError: invalid syntax
On linux
python
Python 3.8.5 (default, Jul 24 2020, 17:46:42)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Crypto.PublicKey.RSA
>>>
Pycrypto version 2.6.1
Found the issue. Posting it here for other's reference as i had a hard time figuring out this issue. Thanks to one of my colleague for finding out the below link.
This is because of setuptools version, refer https://github.com/pycrypto/pycrypto/issues/327
after downgrading the setuptools<58.0.0 it is working fine.
Additionally make sure its not picking up the wheel from pip cache so run below steps
pip cache purge
pip uninstall wheel
pip install pycrypto
Related
I am very new to python so please bare with me.
I have downloaded and installed python 3 on my Mac.
I open up an Idle Shell, it begins:
Python 3.9.6 (v3.9.6:db3ff76da1, Jun 28 2021, 11:49:53)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>>
I then type, to change directory to a repo I downloaded from github:
>>> os.chdir("/Users/XXX/Desktop/spotiminder-master")
Then I type:
>>> python setup.py install
as per the instructions, but I get:
>>> SyntaxError: invalid syntax
What do I need to do here? Appreciate your help.
I'm currently working on a project with anaconda. I was able to install opencv-python with the regular pip3 install (not anacondas version). When I import cv2, its successful.
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
If I copy that package into my anaconda path, and run python with anaconda, import cv2 I get the following error:
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
Is there a way to get around this without using the Anacondas pip install? I don't have internet on the machine I'm working on. I've done this method with other packages and it has worked fine, not with opencv.
I have installed opencv using apt-get. I got opencv2 with the following version and it works fine:
rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ python2.7
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'2.4.9.1'
Then I wanted to install opencv on a conda environment using pip. I got the following version
(olfatf)rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ pip list | grep opencv
opencv-python 3.4.0.14
However, I get the following error when I import the module:
(olfatf)rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Aug 21 2015, 00:53:08)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.conda/envs/olfatf/lib/python3.4/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: libavformat.so.56: cannot open shared object file: No such file or directory
I checked the install libavcodec library and I get the version 57.
(olfatf)rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ ls | grep libavformat
libavformat.a
libavformat.so
libavformat.so.57
libavformat.so.57.56.101
So I want to know why a later version of opencv requires an older version of libavcodec. Also, how can I installed both libavcodec56 and libavcodec57 on my machine ?
I use a raspberry pi with Raspbian Strech
Its not that opencv requires it, Its that whoever compiled the binary of opencv you are using compiled it against libavcodec56. Easiest fix is to compile it yourself.
Also, how can I installed both libavcodec56 and libavcodec57 on my machine ?
Don't. just compile and link against the same version.
I installed the latest version of lxml.etree compatible with Python 3.4. However when I try importing the package, I hit the following error:
> python
Python 3.4.1 (default, Nov 12 2014, 13:34:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /users/vinapai/nxapi/pyats/lib/python3.4/site-packages/lxml/etree.cpython-34m.so: undefined symbol: xmlMemDisplayLast
>>>
I tried using both pip install and easy_install and tried different packages of lxml but consistently hit this error. Any help would be greatly appreciated.
I use Webfaction, and this is the command line for the shared host.
[zallarak#web198 ~]$ python2.6
Python 2.6.5 (r265:79063, Nov 23 2010, 02:02:03)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import stripe
>>>
[zallarak#web198 ~]$ python2.7
Python 2.7.1 (r271:86832, Dec 1 2010, 06:29:57)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import stripe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named stripe
I know there must be a simple way to make it work in all version of Python. I would much appreciate any insight on how to make this work/the concept behind it.
My version of Django runs on 2.7, so the goal is to make it work on 2.7
Your problem is that the stripe module is not installed in each python environment.
I know there must be a simple way to make it work in all version of Python.
You must install stripe in each environment. According to your webhost, you should be able to install them with easy_install. Try this:
python2.7 `which easy_install` stripe
Brian Cain is correct about it not being installed in the Python version you are using. Instead of the command he gave you should run:
easy_install-2.7 stripe
After making sure that the directory: /home/username/lib/python2.7/ actually exists. If it doesn't you can use the command: mkdir -p /home/username/lib/python2.7 to create it.
That will install it in your Python2.7 installation, which you can then use from Django on Python2.7.
Note: If you get the error: "Need libcurl version 7.19.0 or greater to compile pycurl." you'll need to follow the instructions here:
http://community.webfaction.com/questions/6365/problems-installing-pycurl
to install your own version of curl on your account.