New python 3.6 venv giving error on MacOS - python

I have a python 3.5.2 anaconda installation on MacOS v10.11.
$ which python
/Users/<username>/anaconda3/bin/python
If I try to run python command to build a virtual env in the same directory
py-venv $ python -m venv /Users/<username>/workarea/py-venv
Error: Command '['/Users/<username>/workarea/py-venv/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
Then it complains with the error mentioned above. The same error occurs if I use the same commands with python3 instead of python.
Any clues?

Related

Can't run GitHub file through CMD on windows

I'm trying to run a run a file from a GitHub repo using the Command Prompt on Windows. I started with these commands:
python -m pip install virtualenv
python -m virtualenv ocopus_venv
.\venv\Scripts\activate.bat
curl -O https://github.com/zuphilip/ocropy-models/raw/master/en-default.pyrnn.gz
move en-default.pyrnn.gz models
No errors so far, but when I run:
./ocropus-nlbin tests/ersch.png -o book
I got this error: the '.' is not recognized
How can I make this command run properly?
On Windows cmd this doesn't work. Try without the ./ at the beggining. Condering ocropy supports Windows you can run it also wtih python2.7.
python ocropus-nlbin tests/ersch.png -o book
Don't forget you have to run python setup.py install before.

AWS errors when installing requirements with python 2.7 when EB environment is python 3.6

How do I get the aWS EB instance to use the python 3 version that is already installed on the instance?
I can't get a new environment running with Python 3.6 running Django 2.1+.
Local (not in virtual env):
which python -> /usr/local/bin/python
python -V -> Python 2.7.15
which python3 -> /usr/local/bin/python3
python3 -V -> Python 3.6.5
which pip -> /usr/local/bin/pip
pip -V -> pip 18.0 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)`
which pip3 -> /usr/local/bin/pip3
pip3 -V -> pip 18.0 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
Local in virtualenv mstFirst:
which python -> /Users/me/.virtualenvs/mstFirst/bin/python
which python3 -> /Users/me/.virtualenvs/mstFirst/bin/python
python -V -> Python 3.6.5
python3 -V -> Python 3.6.5
which pip -> /Users/me/.virtualenvs/mstFirst/bin/pip
which pip3 -> /Users/me/.virtualenvs/mstFirst/bin/pip3
pip -V -> pip 18.0 from /Users/me/.virtualenvs/mstFirst/lib/python3.6/site-packages/pip (python 3.6)
pip3 -V -> pip 18.0 from /Users/me/.virtualenvs/mstFirst/lib/python3.6/site-packages/pip (python 3.6)
aws --version -> aws-cli/1.16.9 Python/3.6.5 Darwin/17.7.0 botocore/1.11.9
eb --version -> EB CLI 3.14.4 (Python 3.6.5)
eb -list -> * mst-p3
eb -config ->
ApplicationName: mst
DateUpdated: 2018-09-07 02:15:51+00:00
EnvironmentName: mst-p3
PlatformArn: arn:aws:elasticbeanstalk:us-east-1::platform/Python 3.6 running on 64bit Amazon Linux/2.7.3
settings: …
Files:
".elasticbeanstalk/config.yml"
branch-defaults:
master:
environment: mst-p3
environment-defaults:
mst-p3: …
global:
application_name: mst
default_platform: 64bit Amazon Linux 2018.03 v2.7.3 running Python 3.6
default_region: us-east-1
workspace_type: Application
…
".ebextensions/01_packages.config"
packages:
yum:
git: []
python36: []
python36-devel: []
postgresql93: []
postgresql93-devel: []
mod24_ssl : []
commands:
pip_upgrade:
command: /opt/python/run/venv/bin/pip install --upgrade pip
ignoreErrors: false
Error when trying eb deploy, which points to wrong python version (2.7) while trying to run pip install -r requirements.py:
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-jt3_s4in/slugger/
2018-09-07 03:28:35,315 ERROR Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
Traceback (most recent call last):
File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main
install_dependencies()
File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies
check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)
File "/usr/lib64/python2.7/subprocess.py", line 186, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1 (Executor::NonZeroExitStatus)
Remote Instance ssh (eb ssh):
pyhthon -V -> Python 2.7.14
pyhthon3 -V -> Python 3.6.5
Things I've tried:
Replacing the environment AMI with a current version and rebuilding per https://stackoverflow.com/a/47157777/1234721 , but the environment errors with an AMI of "ami-0ff8a91507f77f867" for "Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type"
trying to hook into the YAML config to switch the python versions
re-init using eb init
verified my ssh keys per : https://stackoverflow.com/a/51669982/1234721
Your problem is caused by the wrong version of pip (Python 3.x pip) in the Python 2.7 installation.
The AWS tools are written for Python 2.7
I am also not sure if aws cli or eb has been completely tested with pip 18.
Uninstall pip from the Python 2 directory.
Uninstall eb
Reinstall.
I recommend installing the AWS CLI first even if you are not using it. This will ensure that your Python environment is setup correct for AWS tools.
You did not specify the OS, so I cannot give you OS specific uninstall / install directions.
Using eb init definitely works:
eb init -p "64bit Amazon Linux 2017.09 v2.7.3 running Python 3.6" ...
Then just remove all the python stuff from your .ebextension files.
For the yum section, all I use is:
packages:
yum:
postgresql94-devel: []
There should be no need to upgrade pip.
Try:
backing up and delete .elasticbeanstalk/config.yml
run: eb init
You can then select python version 3.6 within eb init

Virtual Environment Error with Python 3.6.3

I'm not sure why I can't create this virtual environment on my Mac. I get an error on a call to python3 in my environment and when I dig in it seems to be looking for something called ensurepip.
Any idea what I'm doing wrong?
$ python3 -m venv venv_test
Error: Command '['/Users/raysalemi/workspaces/install_mcs_project/venv_test/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
$ /Users/raysalemi/workspaces/install_mcs_project/venv_test/bin/python3 -Im ensurepip --upgrade --default-pip
/Users/raysalemi/workspaces/install_mcs_project/venv_test/bin/python3: No module named ensurepip
$ pip
Usage:
pip <command> [options]

venv doesn't create activate script python3

When trying to create a virtulenv using venv with python 3 on ubuntu it isn’t creating an activate script. It conitunally exits with an error 1.
Following docs and other posts on SO such as https://stackoverflow.com/a/19848770
I have tried creating it 2 different ways.
sayth#sayth-TravelMate-5740G:~/scripts$ python3 -m venv test4
Error: Command '['/home/sayth/scripts/test4/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
sayth#sayth-TravelMate-5740G:~/scripts$ source test4/bin/activate
bash: test4/bin/activate: No such file or directory
sayth#sayth-TravelMate-5740G:~/scripts$ ls test4/bin/
python python3
or
sayth#sayth-TravelMate-5740G:~/scripts$ pyvenv-3.4 test5
Error: Command '['/home/sayth/scripts/test5/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
sayth#sayth-TravelMate-5740G:~/scripts$ ls test5/bin/
python python3 python3.4
How can I get it to fully create a venv?
If I do it as below with stil no success unsure what the issue is?
sayth#sayth-TravelMate-5740G:~/scripts$ python3 -Im venv panda3
Error: Command '['/home/sayth/scripts/panda3/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
sayth#sayth-TravelMate-5740G:~/scripts$ python3 -m venv panda4
Error: Command '['/home/sayth/scripts/panda4/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
Looks like you are using Ubuntu 14.04. It was shipped with a broken pyvenv. There is a simple work around to create venv using Python 3
1. Create venv without pip
python3 -m venv --without-pip test4
or
pyvenv-3.4 --without-pip test4
2. Get pip in your env
source test4/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python
deactivate
source test4/bin/activate
or
pyvenv-3.4 --without-pip myvenv
source ./myvenv/bin/activate
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-3.4.4.tar.gz
tar -vzxf setuptools-3.4.4.tar.gz
cd setuptools-3.4.4
python setup.py install
cd ..
wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz
tar -vzxf pip-1.5.6.tar.gz
cd pip-1.5.6
python setup.py install
cd ..
deactivate
source ./myvenv/bin/activate
Source: HackerNews, AskUbuntu
Anaconda involucred.
If you are using Anaconda or Miniconda this solution may help:
Conda manages python itself as a package, so that conda update python is possible, in contrast to pip, which only manages Python packages. Conda is available in Anaconda and Miniconda (an easy-to-install download with just Python and conda).
So, this command would help:
conda update python
very disturbing for me but well, hands to the keyboard in a terminal window: (click here, see the picture)
Thanks for your attention, have a nice day!
The command:
python3 -m virtualenv env
works for me, whereas:
python3 -m venv env
does not.
This worked for me:
python3 -m venv --without-pip test4
Once I typed that in the terminal, the "test4" venv was created. And the 'activate' script was also created in the 'bin' directory.
To anyone using python3, having trouble with this, just substitute the name of the directory you want to create for "test4" (or rename it later).
That should do it.

On Mac OS X, easy_install fabric and/or easy_install pycrypto fails due to linker error "illegal text-relocation"

When trying to easy_installfabric (or easy_installpycrypto, which fabric depends on), I got the following linker error on Mac OS X:
ld: illegal text-relocation to ___gmp_binvert_limb_table in /usr/local/lib/libgmp.a(mp_minv_tab.o) from ___gmpn_divexact_1 in /usr/local/lib/libgmp.a(dive_1.o) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: Setup script exited with error: command 'clang' failed with exit status 1
I was using a custom install of python, which apparently wasn't compatible with my standard install of libGMP. Building libGMP from source (in my own prefix location, used by my special python install) fixed the problem.
$ bunzip2 gmp-5.0.5.tar.bz2
$ tar -xf gmp-5.0.5.tar
$ cd gmp-5.0.5
$ ./configure --prefix=/path/to/my/special/prefix
$ make
$ make check
$ make install
$ easy_install pycrypto
$ easy_install fabric

Categories

Resources