ImportError, "No module named tweepy" -- Google Appengine - google-app-engine

I'm new to using AppEngine and Python, and I can't figure out why I keep getting the error: ImportError: No module named tweepy
I put pip install tweepy==3.3.0 into my terminal, and it said it was successful. However, it still says it can't find the module.
Do I have to put it into a specific folder? If so, which one/how should I get to it?
Update: When I type pip list tweepy (3.3.0) appears, but the importError is still there
Also, I don't know if this matters, but I'm using Atom and a mac. On my computer I think I have both versions of python (3.6 and 2.7)
Note: when i type in pip install tweepy==3.3.0 now, all it says is:
Requirement already satisfied: tweepy==3.3.0 in /Library/Python/2.7/site-packages
Requirement already satisfied: six>=1.7.3 in /Library/Python/2.7/site-packages (from tweepy==3.3.0)
Requirement already satisfied: requests-oauthlib>=0.4.1 in /Library/Python/2.7/site-packages (from tweepy==3.3.0)
Requirement already satisfied: requests>=2.4.3 in /Library/Python/2.7/site-packages (from tweepy==3.3.0)
Requirement already satisfied: oauthlib>=0.6.2 in /Library/Python/2.7/site-packages (from requests-oauthlib>=0.4.1->tweepy==3.3.0)
Requirement already satisfied: idna<2.6,>=2.5 in /Library/Python/2.7/site-packages (from requests>=2.4.3->tweepy==3.3.0)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Python/2.7/site-packages (from requests>=2.4.3->tweepy==3.3.0)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /Library/Python/2.7/site-packages (from requests>=2.4.3->tweepy==3.3.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Python/2.7/site-packages (from requests>=2.4.3->tweepy==3.3.0)
Update: I'm also trying to import Jinja and getting the import error

You can add your third-party libraries to your app.yaml.
libraries:
- name: PIL
version: "1.1.7"
- name: webob
version: "1.1.1"
Take a look here for reference:
Using third-party libraries
The Python->Standard Environment is limited to this libraries:
Built-in Third-party Libraries
If you need a more flexible Environment choose Python->Flexible Environment: Using Python Libraries

You need to first decide which GAE environment will be used, because both the app code and the development workflow are almost entirely different. Start here: Choosing an App Engine Environment.
Also please note that a lot of the documentation only applies to one environment or the other, but not both. Often the applicable environment is reflected in the doc page URL path (but not always!). You might find it easier to just use the left side navigation bar to remain inside the same environment documentation.
If you choose the standard environment you need to meet more strict sandbox restrictions. You can use 3rd party libraries (as long as they meet these restrictions) in one of 2 ways:
if the library is one of the runtime-provided libraries then you just request it using the libraries: directive in app.yaml
if not then you need to install it (aka vendor it) into your application (not on your local system as you did!)
If you can't meet the standard environment limitations you're left with only the flexible environment alternative, where:
using 3rd party libraries is done differently, see Using Python Libraries
running locally is done differently (can't use dev_appserver.py), see Running locally. You'll need to install all your libraries on the local system as well.

Related

Library conflict when running AppEngine using PyCharm

I am trying to run AppEngine Standard Environment inside PyCharm.
The problem is when I include Google App Engine SDK as part of External Libraries, but it contains multiple version of old libraries that somehow has higher priority than the library I have in my env folder.
Specifically, it is loading jinja2-2.6 which doesn't work for Python 3, even though I have jinja2-2.11.3 in my env/lib.
Pycharm does have a bit of issues with its library system as many users have reported before. To Adjust the version of your libraries in PyCharm you must access the interpreter options relating your python interpreter for your current project, you can access this option by searching in the menu Settings/Preferences or by pressing Ctrl+Alt+S
In this dialog you can view the packages available and their current running versions. You can update the version by clicking on the ▲ symbol next to the version. if you have trouble upgrading to a specific version you may need then you can alway remove a package by clicking on the "-" on the right hand side after clicking on the package you wish to remove. After removing the package you can add a new one by clicking on the "+" button right on top of the "-" button. Here you can search for the package you need and before installing a package, you can check the specific version checkbox to search for the version you require in the dropdown menu next to it.
This link contains images for what i'm explaining here.
Remember that these packages are taken directly from the pip so if you have errors using the interface you can always try to manually edit the packages (also described in the link).
To upgrade a specific package using pip for python3 you can use the following command:
pip3 install --upgrade PackageName

How to interpret suggestions when installing CakePHP via Composer?

When I try installing with command line:
composer self-update && composer create-project --prefer-dist cakephp/app my_app_name
I keep getting this message, which I didnt use to have, now which one is required, which one is not, do I have to download manually everytime?
cakephp/app suggests installing markstory/asset_compress (An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.)
cakephp/app suggests installing dereuromark/cakephp-ide-helper (After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.)
cakephp/app suggests installing phpunit/phpunit (Allows automated tests to be run without system-wide install.)
cakephp/cakephp suggests installing lib-ICU (The intl PHP library, to use Text::transliterate() or Text::slug())
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/lock ()
symfony/console suggests installing psr/log-implementation (For using the console logger)
m1/env suggests installing m1/vars (For loading of configs)
asm89/twig-cache-extension suggests installing psr/cache-implementation (To make use of PSR-6 cache implementation via PsrCacheAdapter.)
aptoma/twig-markdown suggests installing michelf/php-markdown (Original Markdown engine with MarkdownExtra.)
aptoma/twig-markdown suggests installing knplabs/github-api (Needed for using GitHub's Markdown engine provided through their API.)
ajgl/breakpoint-twig-extension suggests installing ext-xdebug (The Xdebug extension is required for the breakpoint to work)
ajgl/breakpoint-twig-extension suggests installing symfony/framework-bundle (The framework bundle to integrate the extension into Symfony)
ajgl/breakpoint-twig-extension suggests installing symfony/twig-bundle (The twig bundle to integrate the extension into Symfony)
psy/psysh suggests installing ext-pcntl (Enabling the PCNTL extension makes PsySH a lot happier :))
psy/psysh suggests installing ext-posix (If you have PCNTL, you'll want the POSIX extension as well.)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
These are only suggestions that may extend the functionality of already installed packages, but everything should work fine without them. For example monolog/monolog will suggest a couple of plugins that will allow logging into different backends. But monolog/monolog will work without them - you may not be able to log for example to Sentry, but monolog will still be usable without this feature.
So usually you can just ignore these suggestions. But you can take a few minutes to check what these suggested packages are actually doing - you can learn about new technologies and solutions that can make your app better and easier to maintain.
If you're really not interested in these suggestions, you can use --no-suggest switch to avoid displaying them on install/update/require:
composer install --no-suggest

`cannot find package "appengine" error` when using VS code

By following this tutorial I created a go lang project and opened it by Visual Studio Code.
The code itself works fine I can run the server, but somehow VS Code shows
cannot find package "appengine" in any of:
/usr/local/Cellar/go/1.8.3/libexec/src/appengine (from $GOROOT)
/Users/ironsand/go/src/appengine (from $GOPATH)
I thought I must set GOROOT for the Google App Engine, but according to this stackoverflow question I shouldn't.
How to make VS Code recognize google app engine library properly?
More info
The appengine package exists in ~/dev/google-cloud-sdk/platform/google_appengine/goroot-1.8/‌​src/appengine
I'm using macOS Sierra 10.12.6.
I did use that tutorial and it's working on my Mac via terminal and via VS Code.
You may follow this tutorial to be able use VS code to deploy GAE app with python:
Deploy GAE app with VS code
• Dont forget to update path of dev_appserver.py in tasks.json.
If that didn't work out, you would need to re-install/init google-cloud-sdk.
Note that it's necessary to provide root privileges during installing/initializing in order to allow installer script to add paths properly.
Last thing: avoid tilde expansion ~ in path. Use absolute path in config.( in general absolute path must be used always unless there is a reason to use relative address with tilde )
Good luck,'.

Managing Demo / Full version of my app in Codename One

I was ordered to deliver an app in 2 versions : one demo/light (limitted features) the other full (all features). I have a boolean in code which tells which one is running. They both run as expected in the simulator or on a test device (iOS and Android).
Now I want to distribute them. So I read that it was possible with XCode to define different targets corresponding to the light / full versions and with Eclipse it was possible to define the base project as a library and then create 2 projects also corresponding to the light / full versions.
Before I start messing around with my app project, is there a recommended way to achieve my goal with CodenameOne maybe via build hints that would change the app name and the boolean inside the code depending on a build hint value ?
EDIT 19/09/2016 (working methodology)
Following Shai's advices here are the steps I followed to generate a light version based on the full one (in case someone encounters the same case) :
Under your IDE (Eclipse or whathever) copy and paste the base package in the src folder and rename it com.packageLIGHT.appName (simply append LIGHT to the package name, don't use underscore or space since it will be considered as an illegal character later by Apple)
=> So now in src folder you should have
src
|- com.packageLIGHT.appName
|- com.package.appName
Then in com.packageLIGHT.appName remove all files except MyApp.java (aka the main file). In this file add import com.package.myApp.*;
3.1. (ECLIPSE) In "Run/Run Configurations" menu copy the existing config and paste it as Simulator_MyAppLIGHT and in arguments change it to "com.packageLIGHT.myApp.MyApp".
3.2. (NETBEANS) The "Run/Set Project Configuration" does not seem to work as expected since any configuration that might be selected leads to the same default behaviour. However applying step 6. and running the project in the simulator afterward has the expected result.
Now you should be able to run both versions by running the different configurations.
For iOS (not sure if it is also needed for Android) you have to generate another pair of provisioning files. So move the existing ones in iosCerts/FULL and use CN1 wizard to generate the "light" version provisioning files where you'll adapt the package name to match "com.packageLIGHT.myApp". Store the generated files in iosCerts/LIGHT. There is no need to overwrite the existing certificates (more on certificate here).
Finally replace in "codenameone_settings.properties" the original package name with the "light" one for the lines codename1.ios.appid and codename1.packageName. Also change the iOS provisioning files to iosCerts/LIGHT or FULL depending of what you want to build.
Now when you send the Android / iOS build to CN1 server it will build either the "light" version or the full one depending on what package is written in "codenameone_settings.properties".
Please note : if at step 6. you get NullPointerException on build.xml on line 469 (android build) or 344 (iOS build) which deals with certPassword="${codename1.android.keystorePassword} (android build) or appid="${codename1.ios.appid}" (iOS build) and you're using CN1 plugin version 1.0.0 20160812 under Eclipse then Shai's comment below may be worth it
If you want 2 distinct versions of the same app then you need 2 distinct packages since the thing that defines the app uniquely in the store is the app package. There are two common ways to do it:
Place functionality in cn1lib and build two apps
Build one app and just swap the codenameone_settings.properties file
The first one should be pretty clear but might be a bit painful to work with as you can't run the cn1lib and might run into issues debugging it.
The second one is actually rather simple. Create the main version of the app then add the package to the demo version and copy the main file there.
To run the demo version just change the package in the IDE "run settings".
Copy your codenameone_settings.properties to a separate file and just replace all the regular package names to the demo package names. When you want to build the "demo" version replace the codenameone_settings.propeties files with one another, you can automate that with a script obviously.

Proprietary C extension for Ruby

I've written some proprietary business logic in C that I want to run from Ruby. I attempted to write it as a gem that was simply included by Bundler from a path internal to the main project; however, Bundler "doesn't build native extensions in that case" (tmoore in the #bundler irc channel).
I would rather not create a separate private repository for this C extension gem. I would also rather not precompile native versions for all the environments. RubyInline does not appear to be an option because the C is more than just a couple functions, makes heavy use of pointers to structs passed between functions, etc.
Are there any options for building C into a project such that the C will be compiled on the target machine via standard bundle installation?
Thanks to tmoore in the #bundler irc channel for pointing me to the following:
http://bundler.io/v1.5/man/gemfile.5.html#PATH-path-
https://github.com/bundler/bundler/issues/1679#issuecomment-11162403
From the former:
Unlike :git, bundler does not compile C extensions for gems specified
as paths.
And from the latter:
I think I'm going to go with "please use git gems if you need to
compile extensions". :path, as an option, is a way to add directories
that you are managing manually to the load path. If you need an
extension built in those directories, you should be doing it yourself
as part of managing that directory manually. :)
So that's the official word. If you want Bundler to compile a proprietary extension, load your extension gem from a private Git repository. (This was helpful: https://gist.github.com/masonforest/4048732.) In order to avoid overly wide privileges, you can:
create a new Github account dedicated to your private repos
grant it read only access to only your private extension repos
create an oauth token for that dedicated Github user: https://help.github.com/articles/creating-an-access-token-for-command-line-use/
incorporate that oauthtoken into your git url in your gemfile:
gem 'your_gem_name', git:
'https://your_oauth_token:x-oauth-basic#github.com/account/project.git'

Resources