Dropbox python sdk import error - python

I am trying to use the dropbox sdk for python. I installed a virtual enviroment and used pip install to install dropbox-sdk. When I try to run the example code (see below) I get a importerror client cannot be found, but if I try to do it from the interactive intreperter it works. So what am I doing wrong. APP key and secret key and acces_type ommitted.

Update: I found the problem, i called my own file dropbox.py and in that file imported dropbox. I accidently imported my own file. Renamed my file and now it works.

Related

Replit error: /usr/bin/env: ‘./python3’: No such file or directory after using PIP

whenever I type, for an example: pip install aiohttp==3.7.3, it gives me: /usr/bin/env: ‘./python3’: No such file or directory is there any way to fix it? (The error is in REPLIT)
I had problems with using aiohttp in REPLIT, I tried uninstalling package files. I "reinstalled" packages, such as "aiohttp" after doing the problem referred to the title popped up in the console.
I ran into this error as well and haven't been able to solve it.
In the meantime, I use python3 -m instead and it works:
python3 -m <module-name> <args>
Well, go to .replit and delete the Variable called hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]
after deleting, go to the file directly and download the module to your computer, then upload it to the file it's not in.
I hope this works,
-JKID_Tech
P.S. I tried this IT WORKS if you get python from your computer then go to the python files or try to find it on the internet for example PyPI

contextlib not found in virtual environment

I have a Python script which has been created to pull data out of a database and present it in an excel spreadsheet. Because multiple people need this script, I have placed the script on a network drive. To run the script, I have also created a virtual environment in a folder on my workstation, which I then copied to the network location. I have a batch file which runs the script using the virtual environment version of Python.
When I run the batch file on my workstation (from the network drive), everything works fine. When another user, who does not have Python installed on their workstation, runs the batch file, they receive the following error:
ModuleNotFoundError: No module named 'contextlib'
The traceback for the error comes from:
virtualenv\lib\site.py
virtualenv\lib\importlib\util.py
Is there something that I am missing when creating the virtual environment? To create it, I used the following commands (on Windows):
mkdir virtualenv
virtualenv virtualenv
\virtualenv\Scripts\activate
pip install [packages required for script]]
\virtualenv\Scripts\deactivate
Any help is very much appreciated.
Thanks for your help. It turns out that a virtualenv does not do what I thought it did. A virtialenv is not portable to other machines/evironments.
I ended up going with pyinstaller to package the script into an application. This was very easy and quick.
To install pyinstaller and create the app, I simply followed the instructions here:
https://www.pyinstaller.org/

ImportError on different server

I have a python script that uses the pytz module and it runs successfully on one server. But I have moved the script to a different server (over SSH), and now when I try to run the code there I get:
ImportError: No module named pytz
Is there an easy way I can get it to run? I believe I don't have the permissions to download new modules...
try to install this module on your new ssh server, by using:
python -m pip install pytz
if you haven't permissions to download any module, try to use a common similar, or compile this script to a .sh or .exe runnable file, on your developer machine.

Python libraries on Web Job

My goal is to run a Python script that uses Anaconda libraries (such as Pandas) on Azure WebJob but can't seem to figure out how to load the libraries.
I start out just by testing a simple Azure blob to blob file copy which works when run locally but hit into an error "ImportError: No module named 'azure'" when ran in WebJob.
example code:
from azure.storage.blob import BlockBlobService
blobAccountName = <name>
blobStorageKey = <key>
containerName = <containername>
blobService = BlockBlobService(account_name=blobAccountName,
account_key=blobStorageKey)
blobService.set_container_acl(containerName)
b = blobService.get_blob_to_bytes(containerName, 'file.csv')
blobService.create_blob_from_bytes(containerName, 'file.csv', b.content)
I can't even get Azure SDK libraries to run. let alone Anaconda's
How do I run a python script that requires external libraries such as Anaconda (and even Azure SDK). How do I "pip install" these stuff for a WebJob?
It seems like you've kown about deployment of Azure WebJobs, I offer the below steps for you to show how to load external libraries in python scripts.
Step 1 :
Use the virtualenv component to create an independent python runtime environment in your system.Please install it first with command pip install virtualenv if you don't have it.
If you installed it successfully ,you could see it in your python/Scripts file.
Step2 : Run the commad to create independent python runtime environment.
Step 3: Then go into the created directory's Scripts folder and activate it (this step is important , don't miss it)
Please don't close this command window and use pip install <your libraryname> to download external libraries in this command window.
Step 4:Keep the Sample.py uniformly compressed into a folder with the libs packages in the Libs/site-packages folder that you rely on.
Step 5:
Create webjob in Web app service and upload the zip file,then you could execute your Web Job and check the log
You could also refer to the SO thread :Options for running Python scripts in Azure
In addition, if you want to use the modules in Anaconda, please download them separately. There is no need to download the entire library.
Hope it helps you.
You can point your Azure WebJob to your main WebApp environment (and thus its real site packages). This allows you to use the newest fastest version of Python supported by the WebApp (right now mine is 364x64), much better than 3.4 or 2.7 in x86. Another huge benefit is then you don't have to maintain an additional set of packages that are statically held in a file somewhere (this gave me a lot of trouble with dynamic libraries with crazy dependencies such as psycopg2 and pandas).
HOW: In your WebJobs files, set up a .cmd file that runs your run.py, and in that .cmd file, you can just have one line of code like this:
D:\home\python364x64\python.exe run.py
That's it!
Azure WebJobs looks at .cmd files first, then run.py and others.
See this link for an official MS post on this method:
https://blogs.msdn.microsoft.com/azureossds/2016/12/09/running-python-webjob-on-azure-app-services-using-non-default-python-version/

Unable to use Flask

I basically used the install command "$pip install Flask" and when I try to run a program it says "module can't be found." Flask is installed in "/usr/local/lib/python2.7/site-packages" but I thought the point of pip was so I could import these packages everywhere. I'm trying to run a file on my desktop and even when I move the Flask folder to the desktop, it doesn't work. Any advice? Thanks!
This may not directly solve whatever problem you are having with path variables, but one alternative would to download virtualenv
Flask actually has a good tutorial on how to accomplish this here

Categories

Resources