I'm trying to get a Django project working with PTVS. The only reason I'm using it is because I have Azure credits and want to deploy there. In Visual Studio, I go to New Project > Python > Django. I chose "Add Virtual Environment". Here is the screenshot:
After the project is created, this is my solution explorer:
You can see django is definitely installed in the environment. But when I right-click on the app and go to Python > Sync DB, I get a bunch of errors says that
ImportError: No module named django.core.management. All the django package statements are underlined and they can't be imported. Any ideas?
When I go back to create another project and I do "Install into Python 2.7 directory," it works fine. So I don't understand why I can't use the virtual environment.
Go to your Projects folder and delete all the application/projects.
Clean the project directory. (By default this is the PATH: Documents/Visual Studio 2013/Projects
Close all the other IDE's and Programs that might be using your
python interpreter.
Set no-proxy in case you are using some proxy settings because it
will prevent Visual Studio from downloading and installing the required
packages.
You might prefer restarting your machine before performing these steps.
It worked for me. I had the same problem.
Below are two useful tutorials to walk you through the entire process.
PTVS 2.0 Beta: Creating a Django Website : A step by step guide
Django and MySQL on Azure with Python Tools 2.1 for Visual Studio
Related
I have installed the Pycharm Community edition and installed the behave 1.2.5 with the following command.
pip install behave
It was successfully installed and it is available in the Pycharm Project Interpreter as shown below.
But I don't see an option to create the .feature file (Gherkin file) when I right click on the project
Do I miss anything over here, in Pycharm professional by default Behave BDD is available. How do I configure the behave with Pycharm community.
AFAIK "BDD support is available only in the PyCharm Professional Edition."
Of course, nothing prevents you from creating a file with the .feature extension but you are not going to see options to run your scenarios. You can get some syntax highlighting using the Gherkin plugin and that is as much as you get in the community edition.
how to install gherkin plugin on PyCharm
You can access the Settings by Ctrl + Alt + s and install the gherkin plugin. I just did that and is helping a lot.
At work we are completing a PoC of Airflow by AirBnB. Standard operating practice is to decouple the development (i.e. DAG creation and python scripts etc) from the runtime environment. I.e. we are not allowed to script directly on the servers (bad practice anyway).
As such, I have configured intelliJ to work with Python (works as expected) in Windows (we are not allowed to have unix workstations) but I cannot find a way to install airflow in Windows. I am new to Python with a Java development background.
As such, how do I setup a local development environment IDEA ultimate for AirBnb/Airflow (there is no documentation ?
I have it working and compiling with the following step:
The steps below are for using intelliJ Ultimate edition, download the python modules.
Download the python extension for InttelliJ Ultimate edition or PyCharm
Configure and install python 2.7 for Windows.
Add the SDK to IDEA
Configure the following proxy details in environment variables to install modules using PIP ->
HTTP_PROXY=http : // user:password#your-company-proxy.com:8080
HTTPS_PROXY=http : // user:password#your-company-proxy.com:8080
(remove spaces, not allowed to post multiple links)
Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27
C:_downloads>msiexec /i VCForPython27.msi ALLUSERS=1
pip install airflow
Create a new project, configure it as a python module.
Download the GIT repository -> airflow
Configure your path correctly, also set a python home and AIRFLOW_HOME.
I installed python plugin for Intellij IDEA.
IDEA version: 14.1.4
Plugin version: 4.5.141.1624
I am on Windows 7 and I have installed python to C:\Python34. Python is added to my PATH variable too.
When I edit python files on IDEA, it shows various errors in my python scripts. Following are some of them.
How can I get rid of these errors?
Here is my python console settings. I cannot set a python interpreter. There's no items in the dropdown.
I had the similar problem when I did not define SDK for project during creation of python project. Unfortunately I could not find any option in settings to do so. But I found some solution. Maybe it is little bit work around but it worked for me.
I just created new project by using File/New/Project
I selected Python type of project and click New to define Project SDK (Unfortunately I could not post picture with example I am pretty new in SO)
After that Idea configured itself in such way that in my old project I was also able to select this SDK. I tried to define such SDK by edition of settings file of IDEA but I was not able to do this in such way.
After defining few SDK It is also possible to change it for one of your module even if you did not do this on the beginning. You just need to:
open configuration file for module module_name.iml file
find there line <orderEntry type="inheritedJdk" />
change it to description of on of Python SDK for example
<orderEntry type="jdk" jdkName="Python 3.4.3 (F:\Python34\python.exe)" jdkType="Python SDK" />
I hope that this will help.
I am using:
InteliJ IDEA 14.1.4
Python Community Edition plugin version 4.5.2 141.106
And python 3.4.3
I'm using visual studio 2013 and the python tools for visual studio.
While setting up the project i've begun adding to the standard VS .gitignore as it doesn't cover the tools. I have a subdirectory labeled .ptvs in my environments folder. Currently it only seems to have logs in it.
Is there any risk that something important ever ends up there? Documentation is lacking in this area.
Thanks in advance.
The Python Tools Visual Studio seems to cache or generate files, logs and DB in the hidden folder .ptvs.
Since those data are generated, you should safely ignore that file and never version its content.
See for instance this discussion around the issue "Visual Studio 2010 freezes with PTVS 2.0RC":
Are you using or can you upgrade to our latest dev build and see if the issue goes away?
You may also want to try deleting the (hidden) .ptvs folder in your virtual environment and recreating the DB from scratch.
I'm looking to be working on a Python app. Does Python Tools for Visual Studio support 3rd-party libraries, such as Twisted?
3rd party libraries will run just fine. To get intellisense against them they'll need to be installed in site-packages or part of your project. If you install them after installing PTVS you'll need to run Tools->Options->Python Tools->Interpreter Options and select the interpreter you have configured and regenerated the completion database. Alternately you can have the libraries as part of your project and they'll be analyzed in real time.
You also seem interested in some specialized app... If that app is a pure Python app that starts up like "python.exe app.py" you'll have no problems at all. You may need to setup a custom interpreter again in Tools->Options->Python Tools->Interpreter Options which points at the specific python.exe that the app is using if it's a special app specific build.
If the app is actually a C++ app which is hosting Python life is a little more difficult. You should have no problems editing the code in PTVS but debugging will probably need to be accomplished by doing Debug->Attach to Process. This should work if the app is hosting a normal Python build and has it dynamically linked. PTVS will discover the Python interpreter and inject it's debugging script into the process. The workflow might be a little cumbersome doing the attach each time after launching but if you're not restarting frequently it shouldn't be too bad
PTVS is just an IDE. So it does not need to "support" any libraries - they just need to be in your PYTHONPATH so your python code can import them.
However, chances are good that PTVS cannot launch a twisted-based daemon using twistd like you would do on the command line...