I installed Django and started a project via cmd yesterday. Today I installed Anaconda with VS Code and I now want to open my Django project in VS Code through Anaconda.
Is this possible? Id like Anaconda to be my interface for all my projects regardless of what they are. Is this possible?
thanks
V
I myself use Anaconda Environment in VSCode for Data Science Projects.
For this, first you need to prepare a virtual env from Anaconda. Here is the tutorial for it in the official documentation : https://code.visualstudio.com/docs/python/environments
Follow this tutorial as it is without missing any line of code they ask you to.
Once you are done setting it up. You just need to start your Django Project in VSCode.
At the bottom where you see Python just click on it and Select Interpreter. From their, a list of virtual envs and Python envs opens up choose the one you created from Anaconda.
You have anaconda libraries working in your project now.
You can also start Jupyter notebook in VSCode : https://code.visualstudio.com/docs/python/jupyter-support#_create-or-open-a-jupyter-notebook
This way you can purely shift to VSCode for all of your stuff.
Thank you
Related
I'm trying to set up a work environment on a new machine and I am a bit confused how best to procede.
I've set up a new windows machine and have WSL2 set-up; I plan on using that with VS Code for my development environment.
I have a previous django project that I want to continue working on stored in a folder in a thumb drive.
Do I move the [windows] project folder into the linux folder system and everything is magically ready to go?
Will my previous virtual environment in the existing folder still work or do I need to start a new one?
Is it better to just start a new folder via linux terminal and pull the project from github?
I haven't installed pip, python, or django on the windows OR linux side just yet either.
Any other things to look out for while setting this up would be really appreciated. I'm trying to avoid headaches later by getting it all set-up correctly now!
I would pull it from github, and make sure you have the correct settings for line endings, since they are different between windows and linux. Just let git manage these though:
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
Some other suggestions:
Use a version manager in linux to manage your python versions - something like pyenv or asdf. It will make life easier.
Make sure to always create a virtual environment for everything and don't pip install anything in your main python. (I use direnv for virtual env management)
The single exception to the previous suggestion is pipx, which I do install in the main python and then use to install things like cli tools, black, isort, pip-tools etc.
Configure VScode to use the pipx installed versions of black, flake8 etc. for linting purposes.
If you're using Docker, enable the WSL integration for your WSL flavour (probably Ubuntu). Note that docker desktop needs starting before your WSL session.
I will be thankful if someone can help me with the following issue.
I am using windows 10
Django version: 2.1.1 with Python version: 3.5
I have my TensorFlow object detection API, that trained my images which is totally outside of my Django project.
However, I created my Django project after that in the same environment that I had my TensorFlow object detection models.
Both of them with the same (python version: 3.5).
Before creating the Django webpage, I always needed to run my 'Object_detection_image.py' from anaconda prompt line, otherwise, I got an error.
My question is: how I can specify my Object_detection_image.py path directory in the setting.py in Django using anaconda prompt line?
When I write my directory like this: C:\tensorflow1\models\research\object_detection
then how I can use anaconda prompt line in this path? because if I write it like this, it doesn't work. please help me.
Thank you.
I did not run it because I have a problem with how to write the path for my TensorFlow project. I thought if they locate in the same environment, I won't get any problem. I mean before creating Django I could not run it directly from the script. I had to use an anaconda prompt line. but now, since i have django i dont know how to do it.
I am using Pycharm and want to install an older version of Django. However, PC only seems to install V2. How can I configure Pycharm to install an older version?
This is about installing an older version, NOT changing a version that has already been installed. I want to configure Pycharm to INSTALL a specific version.
Specifically for installing through PyCharms UI, you can specify which version of a package you want to install in the package manager. Navigate to
File -> Settings(or Preferences on MacOs) -> Project: [project name] -> Project interpreter
and click on the + sign under the cog icon. Then search for Django and specify the version you want to install from the drop down menu below the Description field.
However, if you want to install a different version through the terminal, you should write something along the lines of
pip install Django==[your_version]
As far as I know, there is no way to change the version on creating a new project unless you use your own interpreter when creating a new project.
So you can first create your virtual environment with the django version you want, and then select that venv when creating a new django project:
virtualenv venv
source venv/bin/activate
pip install django==2.1
When you want to create a new project, select Existing Environment instead of New environment using... and use your custom venv.
It's not possible at the moment. The only workaround, as mentioned by Pedram, is to use the existing interpreter with needed version of Django installed.
I filed a feature request about that, feel free to vote and leave comments.
You may also find useful the following feature request https://youtrack.jetbrains.com/issue/PY-33804
I created a django project in pycharm from my desktop computer. Now that I want to work on that same project from my laptop I'm not able to do so. What are the commands to be written in the terminal for continuing the project in pycharm from my laptop? (how do I work in that existing virtual environment and run the server now?)
If you want to work on a same project in multi device, the best option in using git which is distributed version-control system for tracking changes in source code during software development, for more information use the link below:
git
if you want to run your project on a virtual server, you have multi option, which on of them is using pycharm, pycharm has builtin tools for run your project, the other option is using builtin django and python virtual server that could run with this command : python manage.py runserver. for complete information about how run django project virtually, use this link:
The development server
Configure PyCharm for Python/Django
My context
I'm educating myself with Python Flask via the official tutorial.
I'm using Pycharm IDE (community edition) in Ubuntu Destkop 16.
The issue
I open the sample code of this tutorial as a Pycharm project
Got the Invalid Python interpreter error as below snapshot
My question
How can I fix it?
It's looking for a functional Python installation.
If you open the 2 drop-down you've referenced you'll see a selection of Python installations on your machine.
The better option though, is to create a virtualenv for your current project, so click on the cog icon to the right of the Project Interpreter drop-down and click Create VirtualEnv and follow the prompts.
Once created, it should pick that VirtualEnv as the default Python interpreter for that project and your error will disappear, though remember, because it's a new virtualenv, it won't yet have Flask etc installed on it. You can install the Flask library by clicking the + icon underneath the cog and searching/installing for Flask.
Alternatively, create a requirements.txt file on your project root directory, with Flask as the contents, and PyCharm will notice that next time you are in a .py file and suggest to automatically install Flask.