Signurl command requires the pyopenssl library in gsutil in google storage in creatiing signed URL - google-cloud-storage

I am trying Create a signed URL with gsutil .
following is the command
$ gsutil signurl -d 10m path/to/privatekey.p12 gs://bucket/foo
mentioned in site https://developers.google.com/storage/docs/accesscontrol
I also issued a same like command with my bucket name and object as below
gsutil signurl -d 10m C:\Users\Desktop\javascript\service\4e263da.p12 gs://code-sample/File1
but i got following error
"signurl command requires the pyopenssl library try pip install
pyopenssl or easy_install pyopenssl"
.So,i installed PyOpenSSL for window from here
https://pypi.python.org/pypi/pyOpenSSL/0.13 .My python version is 2.6.Still i am getting same error in running the command. So my question why command signurl is still not recognized after i installed pyopenssl in gsutil

Install with
pip3 install --user pyopenssl
and it should works (especially if you're running in the cloud console)!

was getting this error and tried a variety of python pyopenssl options, but this worked for me in the end, on:
Debian 10 with
Google Cloud SDK 345.0.0
gsutil version: 4.63
sudo apt-get install python3-openssl

I had the same problem with Python v3.7.5 and gsutil v4.46.
To fix the issue I installed pyopenssl for Python 2: pip2 install --user pyopenssl

The issue might be because you are using 64 bit system and python
Working with egenix-pyopenssl-0.13.4.1.0.1.9.win32-py2.7 - 32bit and python 32 bit solved this problem for me... Even google document recommends use of 32bits

I'm running Python 2.7 with same issue.
ProcMon was showing that the bundled Python was being executed (%LOCALAPPDATA%\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe) and not Python in the path variable.
I renamed the 'bundledpython' directory and re-ran 'gsutil signurl' and it ran successfully.
Note: this is after the crypto library was installed (https://cloud.google.com/sdk/crypto)

The problem is rooted in the gsutil shell script and the python libraries. The gsutil script expects Python 2.
pip3 uninstall pyOpenSSL
pip2 install pyOpenSSL
After the above I could successfully sign URLs using gsutil

Related

Unable to create virtual environment on CentOS 7.8 and python3.6

I have two servers that are running CentOS 7.8 with all the latest patches as of the date of this post. On one server I can create a venv, and on the other I get an error. Here is the command used to create the venv:
python3.6 -m venv venv
The error is:
Error: Command '['/root/venv/bin/python3.6', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
So it seems there is a problem after the venv is created. In fact, it makes the links to the python interpreters in venv/bin, but the lib64/python3.6 and lib/python3.6 directories that are created have only empty site-packages in them. I get the problem whether running the command with root privileges (as above) or as a non-privileged user. On the other system, which is not quite the same hardware but very similar, I get no errors.
I have tried a bunch of things including completely uninstalling all the python3 rpms and reinstalling them on both systems. The python3 modules installed are:
python3, python3-devel, python3-libs, python3-other-rpm-macros, python3-pip, python3-rpm-generators, python3-setuptools, python3-tkinter, python3-wheel. All these are installed using the centos repos.
I have searched the internet and one thing that works is to use --no-pip. However, not surprisingly, if I do that I get a venv with no pip, which does not work very well. The version of pip that is installed with the rpm is version 9.0.3. However, I have tried upgrading pip:
python3.6 -m pip install --upgrade pip
This installs pip 20.1. Interestingly, it is installed in /usr/local/lib/python/site-packages. In any event, it doesn't change anything and I get essentially the same error message.
I have even gone as far as rsyncing the /usr/lib/python3.6 and /usr/lib64/python3.6 (using -avu --delete) on the two servers so that they are identical. All to no avail. I am at a loss to know what to do.
I can of course hack things to make them work, but since I am using this to automatically build test environments I really need to get it working automatically. Suggestions would be greatly appreciated.
I've had the same issue on CentOS Linux release 7.9.2009 (Core) and solved it by installing the following system packages:
yum install python36-devel
yum install python36-setuptools
yum install python36-virtualenv
python3.6 -m pip install --upgrade pip
Used virtualenv to install the venv into the project-root:
python3 -m virtualenv venv-dev
After sourcing the venv everything looks good and I could install the needed requirements:
. ./venv-dev/bin/activate
python3 --version
Python 3.6.8
pip3 --version
pip 21.1.1 from /project/root/dir/venv-dev/lib/python3.6/site-packages/pip (python 3.6)
pip3 install -r requirements/dev.txt
Successfully installed ...

RASA chatbot rasa.core.policies.ensemble.InvalidPolicyConfig: Module for policy ‘MemoizationPolicy’ could not be loaded

I’ve got this error, just following the « Getting Started with Rasa » tutorial
So I’ve typed:
sudo pip3 install rasa-x --extra-index-url https://pypi.rasa.com/simple
which seems to work fine but when I’ve typed:
sudo rasa init
I’ve got a lot of errors among them:
rasa.core.policies.ensemble.InvalidPolicyConfig: Module for policy ‘MemoizationPolicy’ could not be loaded. Please make sure the name is a valid policy.
I faced the same problem when I tried using - rasa init. This is solved by paying attention to 2 things. When you try to install rasa using - pip install rasa in a virtual environment. This install latest python version, in my case this was 3.8, but the problem was that TensorFlow support was not available for 3.8, So I will suggest-
conda create --name rasa python=3.6
For anaconda or you could also create a virtual environment. Now use
pip install rasa
Now you will notice TensorFlow==1.15.1 will be installed. For rasa to work we will need TensorFlow==1.15.0
pip uninstall tensorflow
pip install tensorflow-cpu==1.15.0
if you want CPU support only otherwise,
pip install tensorflow==1.15.0
This worked for me.
In fact, it was a dependencies nightmare.
So what I’ve done to get a rasa chatbot up and running:
Reinstall dask (but I’m not sure this step is mandatory)
sudo pip3 install "dask[complete]"
Downgraded my version of pandas
sudo pip3 install pandas==0.19.2
Upgraded tqdm
sudo pip3 install -U tqdm
Upgraded OpenAI gym
sudo pip3 install -U gym
Et voilà!
This is a library mismatch error. It is Rasa version error, you most probably installed Rasa 1.7.0 or 1.8.0 you need to downgrade to 1.6.0. After downgrading it solved my problem.
Commands to run :
pip uninstall rasa
After you uninstall, re-install rasa by running the commands
pip install rasa==1.6.0
or
python -m pip install rasa==1.6.0
Try using rasa-x rather than rasa library:
virtualenv -p 3.6.8 rasaenvx
rasaenvx\Scripts\activate
pip3 install rasa-x --extra-index-url https://pypi.rasa.com/simple
rasa init --no-prompt

How to start IDLE that comes with Python 3.6

I am using Linux Mint 18. I installed Python 3.5 and 3.6 using apt-get in the terminal. I can open IDLE of Python 2.7 and 3.5 using commands idle and idle3 respectively. How can I access IDLE that comes with Python 3.6?
Try the command idle3.6. python3 and idle3 are still associated with your system Python, which is 3.5.
Simply typing in idle3.6 should work just like carusot42 mentioned. If it doesn't work, perhaps you might want to see if everything else is installed correctly. Here are the steps I followed which worked perfectly fine for me. I am also running Linux Mint 18. The steps that I followed were:
Installed the prerequisites of Python. Do that by typing in the following commands -
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Download Python using the following command and extract it (use your desired location) -
cd /usr/src
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
sudo tar xzf Python-3.6.0.tgz
The next step is to compile Python source. To do that type in the commands below-
cd Python-3.6.1
./configure
sudo make altinstall
make altinstall is used to prevent replacing the default Python binary
file /usr/bin/python
You should be good to go. You check your Python version by typing python3.6 -V in the terminal.
Once you do that, type in idle3.6 and then Python 3.6.1 shell should open for you.
The Software Manager in Linux Mint lists the Python Packages and IDLE Packages
separately. After you install Python, go look up the associated IDLE package in the Software Manager and install it. Reboot and it should work fine. It worked for me.

Vagrant cannot install nokogiri-dependent plugins

I'm trying to install the rackspace plugin for vagrant (1.5.1):
vagrant plugin install vagrant-rackspace
But it complains
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing nokogiri (1.6.1), and Bundler
cannot continue. Make sure that gem install nokogiri -v '1.6.1'
succeeds before bundling.
However gem install nokogiri -v '1.6.1' and /Applications/Vagrant/embedded/bin/gem install nokogiri -v '1.6.1' both work.
I've looked at a bunch of SO threads and blog posts. Things I've tried that have not worked
Running xcode-select --install
Installing full xcode
brew install gcc-4.2
Remove rvm and rvm version of ruby
Install nokogiri w/ built-in (mac) ruby and vagrant-embedded ruby
Despite the fact that nokogiri installs fine (#5 above) without sudo on both counts, vagrant plugin install vagrant-rackspace still fails...
So, in summary, I can install the nokogiri plugin, however I cannot install the vagrant rackspace plugin, can you help me get the plugin installed?
Related threads
Error to install Nokogiri on OSX 10.9 Maverick?
nokogiri - ERROR: Failed to build gem native extension
Full output of vagrant plugin install vagrant-rackspace --debug
I'm on OSX Mavericks and this worked for me:
Set as environment property:
NOKOGIRI_USE_SYSTEM_LIBRARIES=1
Then install as usual:
vagrant plugin install vagrant-rackspace
Vagrant ships with embedded Ruby and isolated gem environment. So installing gems manually to your "normal" gem environment won't help.
The first issue is that you should never use sudo to run any vagrant command. If possible, please remove ~/.vagrant.d/ or at least chown it recursively back to your own user. You could also try upgrading Vagrant to v1.5.1.
Then please gist/pastebin the output of vagrant plugin install vagrant-rackspace --debug and ~/.vagrant.d/gems/gems/nokogiri-1.6.1/ext/nokogiri/mkmf.log.
The posted solutions didn't work for me. Instead I needed to specify the libxml2, libxslt and libiconv that I installed with homebrew (Do this first).
I installed the gem manually with the embedded ruby with the following [very concise] command line:
/Applications/Vagrant/embedded/bin/gem install \ # select the embedded ruby
--install-dir ~/.vagrant.d/gems \ # install to the vagrant dir
nokogiri -v '1.6.2.1' -- \ # pass options to nokogiri install
--with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 \
--with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib \
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 \
--with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include \
--with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
This worked for me on Mavericks and Vagrant 1.6.1:
CC=/usr/bin/gcc vagrant plugin install vagrant-rackspace
I tried NOKOGIRI_USE_SYSTEM_LIBRARIES=1 but got an error saying that system libxml2 is too old.
Warning: This is a super-hacky solution, though it's hard to call it that.
Yesterday I installed Vagrant on another OSX Mavericks box. Like many other posts I read on SO "all I had to do" was run xcode-select --install and bingo vagrant plugin install vagrant-rackspace worked like a charm.
Today I was mired down in the Bundler code again when it dawned on me that since this is an isolated ruby environment why not nuke my ~/.vagrant.d directory and copy the same directory from the successful build on the other box...
The result? A working vagrant rackspace on my laptop! I'm not sure I'll ever figure out what was really wrong, but if anyone wants a shot at the 100 point bounty, I'm still open to suggestions!
In my case the nokogiri folders and their files located in ~/vagrant.d/gems/gems had wrong rights (user/group).
After changing them to username:staff (username being your console user name), it works like a charm.
Similarly with my case, I have an issue while installing vagrant-omnibus plugin for Vagrant 1.6.3 on OSX Mavericks 10.9.4 and ruby 2.0.0p247 rbenv.
I tried setting the env NOKOGIRI_USE_SYSTEM_LIBRARIES to 1 or true, then update+install but the same error still there.
I found that there is a suggestion in https://github.com/mitchellh/vagrant/issues/3769 to use the specify the baked in nokogiri version and this works for me. So, I also wrote a quick noted for myself to refer this unfortunates issue.
If Nate Murray's solution doesn't work, I found upgrading to a Vagrant version > 1.6.4 fixed the issue (as noted in this Github issue: https://github.com/mitchellh/vagrant/issues/3769)
in my case while trying to install vagrant-parallels, i had to check the Command line tools folder had an error in the naming for some reason. Fixing that allowed nokigiri to work well

Installing psycopg2 into virtualenv when PostgreSQL is not installed on development system

Is it possible to install psycopg2 into a virtualenv when PostgreSQL isn't installed on my development system—MacBook Pro with OS X 10.6?
When I run pip install psycopg2 from within my virtualenv, I received the error shown below.
I'm trying to connect to a legacy database on a server using Django, and I'd prefer not to install PostgreSQL on my development system if possible.
Why not install PostgreSQL?
I received an error when installing PostgreSQL using homebrew. I have Xcode4—and only Xcode4—installed on my MacBook Pro and am thinking it's related to missing gcc 4.0. However, this is a problem for another StackOverflow question.
Update 8:37 AM on April 12, 2011: I'd still like to know if this is possible without installing PostgreSQL on my MacBook Pro. However, I ran brew update and forced a reinstallation of ossp-uuid with brew install --force ossp-uuid and now brew install postgresql works. With PostgreSQL successfully installed, I was able to pip install psycopg2 from within my virtualenv.
Error from pip install psycopg2
$ pip install psycopg2
Downloading/unpacking psycopg2
Running setup.py egg_info for package psycopg2
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/matthew/.pip/pip.log
Preliminary Research
Below are the articles I read as preliminary research:
Installing psycopg2 to use Django with PostgreSQL on OS X
Installing psycopg2 on OS X
Using psycopg2 with virtualenv on Ubuntu JauntyLucid
Postgres, psycopg2, virtualenv install hints
apt-get install libpq-dev
helped me on debian squeeze
From comments:
apt-get install python-dev-is-python3
psycopg depends on pg_config command, and if you don't have it, you can't install psycopg.
If system installation is a problem to you, why don't you try compiling PostgreSQL and including generated bin files in your $PATH? Like:
export PATH=/path/to/compiled/postgresql/bin:"$PATH"
pip install psycopg2
brew install postgresql
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip3 install psycopg2
apt-get install libpq-dev
helped me in debian squeeze too . After that do pip install psycopg2. I faced problem of pg_config not found problem when i was setting up my environment on heroku , now its working fine .
You need to install the python-dev package in order to make use of python extensions such as psycopg2. I don't know how to install packages in mac but I run the following commands to install a python package on my Ubuntu machine.
sudo apt-get install python-dev
Or
sudo apt-get install python3-dev
if you are using Python3.x.
Once the installation is finished run the following command within your virtual environment.
pip install psycopg2
You don't need the complete PostgreSQL installed: you only need the client side libraries.
I solved it in MAC OSX using :
$ wget https://ftp.postgresql.org/pub/source/v9.5.3/postgresql-9.5.3.tar.bz2
$ tar xfv postgresql-9.5.3.tar.bz2
$ cd postgresql-9.5.3
$ ./configure
$ make
$ cd src/bin/pg_config
$ export PATH=`pwd`:"$PATH"
$ pip install psycopg2
Use pip install psycopg2-binary, it worked for me when pip install psycopg2 wasn't working.
Using the method you described in your April 12th update, I was able to install PostgreSQL(+1). Note that I originally was running Python 2.7.1 (32bit) and homebrew threw several errors and warnings regarding using a 32bit version of Python. I have since switched the 64/32 bit version of 2.7.1 and it works like a champ.
Regarding the pyscopg2, I was able to install it into my virtual environment from source by editing setup.cfg. I set pg_config to correct path inside homebrew's Cellar (pg_config=/usr/local/Cellar/postgresql/9.0.4/bin/pg_config). After saving the changes, I ran python setup.py install with zero issues. It's worth noting that I did not set the Mac's default python setting to 32 bit. I used the new 64 bit from start to finish.
After looking over some of the documentation, I think if I added homebrew's postgresql path to the system path I could have used pip to install it.
Reference:
http://favosdream.blogspot.com/2009/09/make-psycopg2-and-readline-work-in-snow.html
Update 6-8-2011:
While porting a project written on OS X to Windows 7, I found out that I had to install PostgreSQL on Windows as well. This ended up creating another user on my start up screen and other things that I just didn't like. While doing some digging I found Windows drivers for PostgreSQL here. I have since uninstalled the full PostgreSQL and installed the ODBC drivers which, thus far, work great.
To address the original question, after doing a bit more digging I think I found the equivalent ODBC for OS X here. I have not had a chance to try them out, but the concept works very well on Windows 7. I will update this when I get a chance to try them out. Until then, I hope this helps.
All from the above doesn't work for me (OS Catalina 10.15.1)
There was a conflict with classical postgres and homebrew version.
Please delete homebrew version by command
$ brew uninstall postgresql
and then install it from the official website:
$ sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
It is actual for a simple psycopg2 install or django-heroku package.
if you have recently updated python or changed default python (let's say from 3.6 to 3.8). The following code
sudo apt-get install python-dev OR sudo apt-get install python3-dev
will be installing/working for the previous python version.
so if you want this command to work for the recently updated/changed python version try mentioning that specific version like python3.8 in command like
sudo apt-get install python3.8-dev
try above with following
pip install wheel
export PATH=/path/to/compiled/postgresql/bin:"$PATH"
sudo apt-get install libpq-dev
sudo apt-get install python3.x-dev **Change x with your version, eg python3.8**
pip install psycopg2-binary
pip install psycopg2
As I never needed to install postgresql database on this server I installed the following libraries on Ubuntu 14_04 version before running pip install psycopg2 on the same server
apt-get install libpq-dev python-dev
and then executed pip install psycopg2 within virtual env.
Output
Collecting psycopg2
Using cached psycopg2-2.6.1.tar.gz
Building wheels for collected packages: psycopg2
Running setup.py bdist_wheel for psycopg2
Stored in directory: /root/.cache/pip/wheels/e2/9a/5e/7b620848bbc7cfb9084aafea077be11618c2b5067bd532f329
Successfully built psycopg2
Installing collected packages: psycopg2
Successfully installed psycopg2-2.6.1
I know you are asking for development environment but if you are deploying on server say, Heroku.
Just add below line in the requirements.txt of your project.
django-heroku==0.3.1
As this package itself will install the required packages like psycopg2 on server deployment.
Try to specify the version and it'll works, do it inside the venv
pip install psycopg2-binary==2.8.6
based on my experience, apt install libpq-dev then try to install psycopg2 inside venv will fix many issues, however for more information you can refer to this link:
https://www.psycopg.org/docs/install.html