Cannot install modules via pip running on python 3.4 - python

I have been trying to install various modules that I need to have to run this script:
https://github.com/austingandy/slack-evernote/blob/master/slackwriter.py
I am working off a Mac, and my python --version is:
Python 3.4.3 :: Anaconda 2.3.0 (x86_64)
And I have for python -m pip --version:
pip 8.0.2 from /Users/dhruv/anaconda/lib/python3.4/site-packages (python 3.4)
However, for example when I run pip install evernote I get errors like:
Collecting evernote
Using cached evernote-1.25.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/cj/5gs43w4n2tz313rrnz9_htf00000gn/T/pip-build-0y7hm202/evernote/setup.py", line 6
exec x
^
SyntaxError: Missing parentheses in call to 'exec'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/cj/5gs43w4n2tz313rrnz9_htf00000gn/T/pip-build-0y7hm202/evernote
I have a feeling that these errors are because the setup.py code that pip has is in python 2.7 format, and my environment is 3.4, but how can I overall install all the packages I need to run this script? Would I change to python 2.7, install in that environment, and then repackage the setup of evernote into python 3.4 format? If so, how?

AFAIK, Evernote SDK for Python 3 is not yet supported.
https://github.com/evernote/evernote-sdk-python3
This is a test SDK! The official Evernote SDK for Python doesn't
support Python 3 yet; this repository is an experiment as we try to
migrate.
You can try installing manually from the link above or downgrade to python2 in your virtual env.

While it is possible to migrate a script from Python 2 to Python 3, doing it right isn't trivial. You could try using 2to3 but I suspect it won't quite do the job.
The easiest is to just use virtualenv with Python 2. I'm not sure how it is on Mac but on Linux you can just have both versions of Python installed in parallel and you can pick the one you need in your virtualenv as e.g.
virtualenv -p python2 venv
where python2 is your Python 2 binary and venev the directory you want tot install the virtualenv into.
Where you might run into trouble is the activate scripts which are only available for specific shells. However, you could probably adapt one if none works out of the box.

Related

Terminal can't find version of python despite it being installed

I'm trying to install packages on multiple versions of Python. I'm currently running 3.8.8, and 3.11.0.
Following this post Install a module using pip for specific python version
called
python3.11 -m pip install pandas
which results in
File "<stdin>", line 1 python3.11 -m pip install pandas SyntaxError: invalid syntax
This seems to indicate an issue with python, so I double checked that python3.11 is installed.
the python3.11 works in isolation seems to work.
I don't understand why the install command isn't working.
If you’re using Linux try just
python3 —-version
In Windows you may need to add path to folder with installed Python to PATH variable.
Check your environment variables, you could try removing the variables pointing to the 3.8 version until you get the packages you want installed.
You could also try navigating to that python 3.11 installation directly, and executing the python shell from there, then run the command.

Installed Selenium on Ubuntu, but can't import it

I am using Ubuntu Server 18.04 LTS(HVM)-free tier to run my python script. I connect with the Key to the server with Putty. I manage my files loaded onto the the server using FileZilla. After I install python on the server with sudo apt install python3 I install Selenium using pip install -U selenium. The process is a success. I then load my python script through FileZilla and then try to run the python script. Like most that have asked I get the error:
Traceback (most recent call last):
File "BinaryAutomation.py", line 1, in <module>
from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'
Now please understand this. I have tried to install selenium manually by installing and unachieving the file found here, which basically downloads the setup to be loaded using python setup.py install. I do not have permission to paste anything under tmp\usr\bin I have tried that. How do i get around this problem?
You probably have other versions of python/pip installed. Install packages using pythonx -m pip install ... with pythonx your python version (python3 I presume) to avoid installing packages for a version of python that you're not using to run your scripts.
For more details check: Why you should use python -m pip - Snarky
Ubuntu generally follows PEP 394, which says that the command python should be Python 2. So, use python3 instead of python. That extends to PIP too, so I would say to use pip3 instead of pip, but that method is becoming outmoded; use python3 -m pip instead.
This is assuming you haven't changed the python and pip commands.

aws CLI install window

I am having trouble installing the aws CLI for windows.
I am following these instructions here
It requires that I have Python 3.6.2 but I have Python 2.7.6 when I run python --version
After I run
pip install --user --upgrade awscli
and then try to run
aws --version
nothing happens.
I tried setting my path in Environment Variables but it still won't work.
After this, I tried to upgrade my python version by installing python 3.6 on their website, but my python version won't update when I run python --version.
Could this be that start of why I cant install the CLI?
Use this link to download and install AWSCLI Download the AWS CLI MSI installer for Windows
then go to C:\Program Files\Amazon\AWSCLI or where-so-ever you have installed this and set the path in Environment variables.
Cheers!
Have you gone through the steps on the amazon website? Python 2 and 3 are quite different from what I understand.
https://docs.aws.amazon.com/cli/latest/userguide/installing.html
The AWS script you are running is really just a python program. I recommend verifying install paths, and possibly use their bundled installer found on the page above, about half way down.
At first make sure you have installed python3. Check it with command:
Try to verify python version with command(on centos or redhat):
$ rpm -qa|grep python3
And then make sure python3 has been added to $PATH
$python3 --version
And I think you need to install pip3 for python3.X.
$yum search python3|grep pip
And then install the package you need with command
$ pip3 install --user --upgrade awscli
You can develop Python software for AWS in both Python 2.x and 3.x. The CLI is written in Python 2.x.
You can have both Python 2 and Python 3 installed on your system. You can either specify the python.exe manually using its full path (not recommended but I do this all the time) or by updating your environment PATH variable to point to the correct Python installation. I use a batch file so that I can switch back and forth between Python 2 and Python 3.
When you run "pip install --user --upgrade awscli" the version of Python that is running determines the awscli package that is downloaded and installed.
For Microsoft Windows, AWS provides an MSI installer package that contains everything that you need including the correct version of Python 2.7. I recommend that you start with the AWS Windows MSI and then learn how Python works (environment) on Windows.
Keep in mind that Python 2.x is going away. This is not official but plan for January 1, 2020 as the drop dead day. This means where possible develop for Python 3. IMHO it is time to stop developing for AWS in Python 2.x.
If you have choco installed the following will work....
choco install -y awscli
$env:Path += ';C:\Program Files\Amazon\AWSCLI'

Python running setup.py through cmd doesn't work?

So I'm trying to install via cmd using a setup.py file..
However, when I try to install it through CMD, this happens:
The first way you were trying to install it is correct python setup.py install, however you need Python 2.x for this installer to work. You are in a Python 3.2 environment and it appears that this module has not been updated to work with Python3 at this time.
http://ocemp.sourceforge.net/manual/installation.html
The print bdist.bdist_base, self.install_dir statement is Python 2.x syntax. If it were compatible with Python3, it would be print(bdist.bdist_base, self.install_dir)
----------
If you require development in both Python3 and Python2, I highly recommend installing Anaconda
https://www.continuum.io/downloads
You can set up multiple environments with whatever versions of Python that you want. Then you can activate each one as necessary.
http://conda.pydata.org/docs/py2or3.html

Flask installation on windows vs Ubuntu

I have cloned the git repository of flask(https://github.com/mitsuhiko/flask). I run Python 3.4.1 on both my windows and ubuntu machines. To install flask(on windows), I just change directory to flask repository on my machine and run python setup.py build install . Flask successfully installs and runs. When I try repeating the same steps on ubuntu, it simply throws an error saying
Traceback (most recent call last):
File "flask_example.py", line 1, in <module>
from flask import Flask
ImportError: No module named 'flask'
I tried installing flask through pip, pip install flask and by using "virtualenv" with easy_install as well. I still get the same error. Can anyone tell me what the issue could be?
In all Ubuntu versions so far, pip command defaults to one that installs packages for the latest Python 2 version installed, i.e. most probably Python 2.7; this is the python that will start with python command.
Python 3 instead is runnable as python3 or python3.4; there is a corresponding version of pip, such as pip3 (for the default Python 3 version), or pip3.4 for the pip that specifically installs the packages for the Python 3.4 versions.
Most notably, pip does not know anything about what are the possible aliases in the command shell (bash, zsh), and thus is completely oblivious to those.

Categories