GAE - Setting VM to true and shared libraries altogether - python

I've been trying to use MySql when VM true flag is setted to true on my app.yaml
but this error is thrown: appcfg.py: error: Error parsing src/app.yaml: The "libraries:" directive has been deprecated for Managed VMs. Please delete this section from your app.yaml, use pip (https://pip.pypa.io/) to install
your dependencies, and save them to a requirements.txt. For more information, please visit http://cloud.google.com/python.
I didn't find anything specific for this error, where should I put this "requirement.txt", anyone had this issue?
Thanks!

If you're working with flexible environments (previously called Managed Virtual Machines) then you can't use the "libraries" directive in your app.yaml in order to activate third party libraries. Instead of that you should use pip to install your dependencies. From oficial docs;
Requirements.txt and the Python package manager pip are used to
declare and install application dependencies.
The documentation also is explicit when the author write;
Requirements.txt defines the libraries that will be installed both locally and when
deploying to App Engine.
You should put the requirement.txt file in the root directory. Here you can see a example where flask library was imported.
In your development environment you can run the following command in order to install your declared libraries.
pip install -r requirements.txt
Pip is default way to install libraries in python envs. Here you can find a very nice documentation.
Update:
You should use the following command to deploy:
gcloud proview app deploy
Take a look here for more details.
Also, here there is a official example of your use case. I can see a little difference, the author is using PyMySQL==0.7.3 instead of MySQL-python.

Related

I wanted to install the PIP module on the server but i cant install anything on the server as I do not have root access to it

I wanted to install the PIP module on the server but i cant install anything on the server
as I do not have root access to it ..
Support suggested -
You cannot (and we will not) use "pip" to install them into the system Python directories. You will need to manually build and install it into your build directories in your development server and then package it with your code.
Instructions for separating the python "build" step from the "install" step can be obtained from wherever you got the module.
Here are some instructions on the Python website that may be useful:
https://docs.python.org/2.7/install/index.html#alternate-installation-the-user-scheme
You could just create a virtual environment and install your packages there
https://docs.python.org/3/library/venv.html

Pyramid not included in Python virtualenv

I'm an experienced developer, but not very familiar with Python and Pyramid.
I'm trying to follow some (a bit old and unclear) instructions on deploying a Pyramid web application. My OS is Ubuntu 16.04.
The instructions say to install virtualenv and Pyramid - I do so with apt install virtualenv and apt install python-pyramid. Then they say I should run the app in a virtual environment, so I build that with virtualenv . -ppython3, and activate it with source bin/activate. I install the application from a ready-to-run buildout from GitHub. The buildout includes a "production.ini" file with parameters to pserve.
But Pyramid is not included in the virtual environment built with virtualenv. (There is no "pserve" in the bin directory, e.g.) So I can't run the applications with bin/pserve etc/production.ini, as the instructions say. And if I try with only "pserve", I get errors when trying to access files like "var/waitress-%(process_num)s.sock". Files that the app excepts to find in the virtual environment.
I've looked for flags to tell virtualenv to include Pyramid, but couldn't find any. Am I overlooking something? I'd be most grateful for some help! :-)
/Anders from Sweden
Perhaps you might want to try installing Pyramid in your virtual environment using pip, since apt-installed libraries are installed into /opt, rather than being visible to Python. In the guide, it seems like you're wanting to install Pyramid through the virtual environment so that it can be used by your program, so I think you'd be best using pip rather than apt-get. I did a quick Google search, and it seems like this is the library you need. Here, all you'd have to do is run the installation command once you've already entered the virtual environment with pip install pyramid. This way, you should only have access to it within the virtual environment, as well!
You mentioned it's using buildout - I assume this is zc.buildout. buildout usually manages its own virtualenv and handles installing all of the necessary dependencies. It really depends on how that buildout is configured as there's no standard there for what to do or how to run your app. I would normally expect pserve to be exposed in the bin folder, but maybe another app-specific script is exposed instead.

Deploy CLI tool as package

I develop a cli tool with Python for in-house use.
I would like to introduce pipenv to my project to manage "dependencies of dependencies". It is because I encountered a bug due to a difference between production environment and development environment.
However, MY cli tool is installed as a package.(httpie and ansible takes this strategy).
So, I have to specify all dependencies in setup.py.
How should I import "dependencies of dependencies" in Pipfile.lock to setup.py?
(or should take other method?)
It is suggested that you to do this the other way around. Instead of referencing dependencies in Pipfile, you should list them in setup.py instead, and reference them in Pipfile with
pipenv install -e .

why doesn't pip freeze > requirements.txt output Django?

I'm trying to deploy my Django site on Heroku, and thus, I need a requirements.txt file with the necessary packages that Heroku needs to install for me. I understand Django is a necessary package to be installed. Unfortunately, Django isn't included in the file when I run pip freeze > requirements.txt. Why is this? I'm not sure what to show you so you can tell me what's going wrong. Let me know and I'll add it. FYI the site hosts just fine on my local computer, so Django is definitely installed.
Sounds like you are working in a virtual environment, yet your Django dependency is installed globally. Check which Python packages are installed globally and uninstall Django (you probably don't need it globally). Then install it into your virtual environment. Now the freeze command should output Django as well.
General note: Most packages should be installed into your project virtual environment. There are only few packages where it makes sense to install them globally (eg aws management tools).

Pip Wheel Package Installation Fail

I try to run pip wheel azure-mgmt=0.20.1, but whenever I run it I get following pip wheel error, which is very clear:
error: [Error 183] Cannot create a file when that file already exists: 'build\\bdist.win32\\wheel\\azure_mgmt-0.20.0.data\\..'
So my question is where or how I can find that path? I want to delete that existing file. I have been searching my local computer, searched for default path in Google, but still didn't find any solution.
Also is it possible to tell pip wheel to output full log? As you can see that full error path is not displayed. I'm using virtualenv.
We can see the description of virtual env at the official python guide:
To help manage external package dependencies, Azure Git deployment supports the creation of virtual environments.
When Azure detects a requirements.txt in the root of the repository, it automatically creates a virtual environment named env. This only occurs on the first deployment, or during any deployment after the selected Python runtime has changed.
You can directly modify the dependencies and versions of them in requirement.txt, then deploy your python app to Azure Web App via git, Azure will update the python packages automatically. You can check the packages in the virtual env folder which path is env\Lib\site-packages in the root directory of your site. You can login on the kudu console of your site to check your files of you site online, the URL should be: https://{your_site_name}.scm.azurewebsites.net/DebugConsole .
Additionally, according your description, it seems that you use the global python environment to run pip install command which may directly install packages in your global python environment. To install packages in your virtual env, you need to run the similar command env\scripts\pip install -r requirements.txt in your root directory of your application. Please refer to Web app development - Windows - command line for more information.
have you tried uninstalling and reinstalling?
I tried pip wheel azure-mgmt and that installed -0.20.1 for me.
The directory for mine is /Users/me/wheelhouse, so you could look there. I found that in the initial log of the build.
#Amir,
One option is that you could generate the requirement.txt file and remove your virtual environment if you used Visual studio to develop your application. Then you can add a new virtual environment for your project and install all packages from requirement.txt file. Or after removed your virtual environment, you can try pip wheel azure-mgmt command.
And another option is that you can follow this similar issue:https://vilimpoc.org/blog/2014/01/18/time-robbing-python-errors/
The blogger modified the LOCALAPPDATA path to resolve this issue. Please try it.

Categories

Resources