I am currently in the middle of a Django project and considering switching from Visual Studio Code to Pycharm but after activating the Virtual Env it is not showing any Project Interpreter.
Also when I type in the terminal python manage.py runserver it is saying bash: python: command not found
Is there a way to continue the project using pycharm or do I have to install everything from start?
Sure you can proceed using any other IDE, in your case PyCharm.
Make sure that you define the Python variable in your PyCharm Settings so everything can be interpreted accordingly and to ensure that all required packages are accessible.
Go to File/Settings/project:Foo in your PyCharm IDE and then check for the Interpreter to be set up.
Additionally you might consider to scan/run your requirements.txt once again. Just to be sure.
if your using linux then install django to your project, pip install django
Related
I am new to programming and started working on Linux, now I want to switch to windows and open my project there, look at the tutorials, it is written to activate the virtual environment in the Settings / activate.bat folder. but in my project there is no such folder and such file with the extension .bat. what should I do?
Please download & Install interpreter from https://www.python.org/downloads/
(make sure you are using windows 10, because previous
version create problems)
Download pycharm professional addition (if you have university account) other wise go for community https://www.jetbrains.com/pycharm/download/
Click for Django project
Set the interpreter
Go to. manage.py task
Run command migrate
Enjoy
First thing get all the requirements like the library you installed through pip inside
a txt file by writing this command pip freeze > requirements.txt.
Get only the source folder where you made the project and app.
Create a folder.
Create an environment inside the folder. (virtualenv name_of_the_env)
Go inside the env you created and activate the Script. (.\Scripts\activate)
Copy the source folder inside the env and either you can install all the library
manually using pip or you can use requirement.txt that you have created to install the
library by writing this command pip install -r requirement.txt.
You need python and pip installed to work
I am trying to use chartit in django and in its documentation it says add chartit to INSTALLED APPS in "settings.py".
When I try to do that, it gives this error:
ImportError: No module named 'chartit'
How do I import it?
Thank you.
PS-Sorry, it's a silly question.
You missed installing it with pip install django_chartit.
EDIT:
The error you described is thrown by python if a module is not found in the running environment. You need to make sure, that you've installed it in the environment that is used by your django.
Try typing pip list in the shell you usually use to kick your django with python manage.py runserver to figure out what is installed there.
If your django lives inside of a IDE like PyCharm - you need to check the project settings there for the environment used to launch django.
As you don't use virtualenv (which is highly recommended) you install your modules system wide. If you are on linux there might be python3 and python (which is python 2). If your pip belongs to python2 and you have installed django in python3 or vice versa this might be the issue.
from chartit import DataPool, Chart
I was trying to use tensorflow in Pycharm IDE.
It seems that in Pycharm, it is one-click to install a package. It was very easy with bumpy. Now error occurs when I was trying to install tensorflow.
Tensorflow was installed through terminal on Mac, as screenshot shows, using the command
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl
(Refer to https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#pip-installation)
Any suggestions ? Thanks.
If you install tensorflow with the virtualenv option and want to use it from Pycharm for a project, you need to set up a corresponding virtualenv interpreter. There are a few solutions on the forum, for example How to get VirtualEnv TensorFlow to work in PyCharm?, however, that one didn't work for me with a "python packaging tools not found pycharm" error.
This is a working solution for me, first create a virtualenv from Pycharm and then install tensorflow there:
In Pycharm, Preferences -> Project interpreter -> Create VirtualEnv -> give the virtualenv a name and location of your choice, and select "inherit global site-packages" option -> OK.
In command line, install tensorflow in the virtualenv location you created in Step 1. For the above case, the location is ~/tensorflow_pycharm, therefore, run command virtualenv --system-site-packages ~/tensorflow_pycharm
In Pycharm, select the created project interpreter, and select the tensorflow package, double click to install the package.
If Step 3 is successful, set run configuration, and try run a sample program.
Update - Nov. 1, 2017:
Tried successfully with Latest Jetbrain PyCharm Community Edition (2017.2.4) and Python 2.7.14, with Installing with virtualenv of https://www.tensorflow.org/install/install_mac.
Install tensorflow with virtualenv
Add Local to Project Interpreter.
Run the script
Generate graph
Run tensorboard --logdir=/tmp/tensorflow_logs in Terminal of PyCharm
Go Preferences and search for the interpreter. You may see several interpreters. Select any interpreter which has the tensorflow package installed.
Check out the installed packages and double check the versions of tensorflow as shown in this picture.
To summarize (on Mac) :
Step 1, get latest Python (2.7.11 today) on Pycharm:
Pycharm, can not find Python version 2.7.11
Step 2, follow "Pip Installation" of https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#download-and-setup
Step 3, Pycharm-- preference -- project interpreter, install the latest versions of numpy, protobuf, six.
Tensorflow import error on Pycharm (Mac)
Note, maybe have to click the "specify version" when installing.
Step 4, Pycharm-- preference -- project interpreter, install the latest version of tensorflow (v 0.8.0 today).
Note, if not find v0.8.0, then maybe have to manually click "Manage Repositories" and then add the link of Step 2 (https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl)
These steps worked well on both Mac computers of mine. Thanks for all helps during the procedure from contributors.
Steps I followed
1. Use the virtualenv option in tensor flow's official guide for installation and follow the steps exactly to install and set up tensor flow. Although we've already created a virtual environment here, I created a separate one for Pycharm projects.
This is how you do it.
1. Create a new project. Go to Preferences. Go to interpreter and create a new virtualEnv. Give it a name and check on the box "inherit global site-packages". Press "OK".
creating a virtualenv
Below are a list of Packages. Here's where I couldn't find tensor flow initially. If this is the case, there's a + symbol on the bottom left. Click on it and manually search for "tensorflow". Click on "install package" on the bottom left.
installing tensorflow package
After the installation is done press OK.Close this screen. Tensorflow will now appear on the installed packages list.
Press ok. Now test your installation with a program.
import tensorflow as tf
hello = tf.constant("hello TF")
sess = tf.Session()
print(sess.run(hello))
Hope this helps.
PyCharm seems to ignore the configured virtualenv,
and use the base interpreter instead.
In my project at /Users/janos/dev/git/github/bashoneliners I have a virtualenv subdirectory, strictly with my project's dependencies installed in it:
$ . virtualenv/bin/activate
(virtualenv)janos at kronos in ~/dev/git/github/bashoneliners on master
$ pip -V
pip 1.5.6 from /Users/janos/dev/git/github/bashoneliners/virtualenv/lib/python3.4/site-packages (python 3.4)
(virtualenv)janos at kronos in ~/dev/git/github/bashoneliners on master
$ pip freeze
Django==1.9
Markdown==2.6.5
PyJWT==1.4.0
defusedxml==0.4.1
oauthlib==1.0.3
pep8==1.6.2
pyflakes==1.0.0
python-social-auth==0.2.13
python3-openid==3.0.9
requests==2.9.1
requests-oauthlib==0.6.0
six==1.10.0
tweepy==3.5.0
But if I add this virtualenv as Project Interpreter in PyCharm,
it shows completely different packages:
These packages are the same as in my system's base interpreter /opt/local/bin/python. This drives me nuts, I really need to use the packages from the virtualenv, not from my system.
This is with PyCharm Community Edition 5.0.3.
I didn't have this problem before with older versions of PyCharm.
I tried creating a completely new virtualenv,
both on the command line and using PyCharm,
and invalidating caches and restarting, but nothing seems to work.
PyCharm always shows the same list of packages,
and the packages of the virtualenv.
Even if I create an empty virtualenv within PyCharm,
it doesn't start empty, but filled with the same list of packages.
My project works perfectly when I run things on the command line,
such as running Django management commands, unit tests, everything.
I only have problems in PyCharm.
If I try to install packages, for example Django,
using PyCharm,
I get this error:
Of course permission denied on /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages, that's the system interpreter.
It should be trying to install the package there,
but in /Users/janos/dev/git/github/bashoneliners/virtualenv.
Clearly it's not using pip from the virtualenv, but from the system.
I need to make to use the one from the virtualenv.
This is logged as a bug in the issue tracking system of JetBrains,
so hopefully it will get sorted out soon.
https://youtrack.jetbrains.com/issue/PY-18074
A possible workaround is to fall back to a previous version of PyCharm:
https://confluence.jetbrains.com/display/PYH/Previous+PyCharm+Releases
As of 2016 Jan 6, virtualenv works fine for me in PyCharm 4.5.4.
Some of the virtualenv previously registered using PyCharm 5.0.3 appear invalid, but that's fine. I actually deleted all registered interpreters and re-added only the virtualenv I needed.
An odd thing with this older version is that sometimes PyCharm shows the incorrect Python version (2.7 instead of 3.5), but it shows the correct list of modules as per the virtualenv, and the editor doesn't show build errors, so the Python version mixup doesn't seem to cause problems (just a bit scary).
Im testing Python Tools For Visual Studio, I create a django project, make a SyncDB and install django admin with no problems, but now Im trying to make Data Base migration like: Django 1.7 Migrations. the point is that i cant figuer out how to do that. I serched in google and find this: How to run django database migrations with PTVS?. So the migration command is not wraped. I tried using Windows Command Prompt and install C:\Python34\;C:\Python34\Scripts; PATHS but when i type a django command like python manage.py runserver appears No module named 'django'. It seems that i am not pointing to my django project virtual env, but i dont know how to do that.
Execute command in my django app env path does not work neither.
Image:
Thanks a lot!
Before using of virtual env you should activate it. Execute env\activate or env\bin\activate. Not a windows guy so I'm not sure which path virtualenv uses on Windows :-)
You have to activate virtualenv. Go to env/Scripts directory and run activate.bat. Then go to your main project directory and try again python manage.py runserver. If you still see No module named 'django' make sure that django is installed in this environment try pip install django.