Pycharm windows linux terminal

Using linux console in pycharm

I’m new to pycharm, virtualenv, linux and git. I’ve recently begun a journey of using djangoto make webapps. Before I used sublime to make scripts however now a more complex project management system such as pycarm was needed. I actually wanted to get a linux VM and go down that road but was advised that windows python IDE such as pycharm would be suitable I recently learnt the importance of dependencies and how to use virtualenv. However in this tutorial, under the ‘How do I use my shiny new virtual environment?’ it starts using commands such as:

Neither of which my pycharm console would understand. I could use a console emulator such cmder to use the commands but then I would remove the convience of using the IDE’s integrated one. Should I upgrade to a linux VM ? Or can I install a package that allows me to use such commands in PyCharm. As a bonus question, what are the commands in that tutorial ? are they linux commands? when ever i see $ . is that the linux console ?

yes. they are linux (or bash) commands. It would be a good idea to have a linux vm. Tools like cygwin does offer a linux like environment in windows but its not as complete as a linux distro. If you are looking for a light weight linux distro you go with «Lubuntu». Or if you got enough RAM and CPU then you can go with Ubuntu.

They are linux commands. $ means Linux prompt in console. If you use tutorial which use Linux then use Linux too.

2 Answers 2

You can accomplish this using Vagrant: https://www.vagrantup.com/

You can use Vagrant and VirtualBox to setup a Linux VM (distro of your choice) and then install all of your Python dependencies in the VM. Once you have that setup, you can tell PyCharm to use the Python interpreter in your VM by following these steps:

  1. Open the project settings dialog box in PyCharm.
  2. Expand Project: (your project name) on the left side.
  3. Click on Project Interpreter.
  4. Click on the cog icon on the upper right side of the window and select Add Remote.
  5. Click on the Vagrant radio button.
  6. In the Vagrant Instance Folder box, select the directory your Vagrantfile is located in.
  7. In the Vagrant Host URL box, make sure ssh://vagrant@127.0.0.1:2222 is specified.
  8. Click OK.

Since Vagrant is compatible with Windows this solution should work for you. I have done it successfully using macOS and it works great. Good luck!

I got this to work on Windows 10 with Anaconda Prompt. This terminal which comes with Anaconda, creates a «base» environment with a linux-like virtual machine and your Windows file system (C:\\) mounted to /c, and has bash installed with common Unix commands like cd , ls , chmod , echo , cat , . Running programs from bash with access to environment variables is much nicer than Windows Powershell etc.

Читайте также:  Kali linux apt get не работает

Now to get your Terminal in Pycharm to use Anaconda Prompt instead of cmd.exe, I followed this answer. After installing Anaconda and/or Anaconda Prompt, right-click -> Open File Location -> right-click the shortcut -> Properties -> copy file path. Then use your file path instead.

Conda is great for package environment management. Learn more about it here. For Django + Conda specifically, read here. You can also use pip to install from Python package indexes, github repos, and requirements.txt files instead. Unless you know how Anaconda Prompt works, I don’t recommend creating your own environments from scratch. What worked for me was:

(base) C:\Users\wassadamo> conda create -n mynewenvironment --copy base . (base) C:\Users\wassadamo> conda activate mynewenvironment (mynewenvironment) C:\Users\wassadamo> ls folderA folderB file.txt Works! 

Whenever I try running conda deactivate to leave the base environment, my bash commands would stop working. So clone base as above.

Another tip: if you want to run shell scripts from Terminal within PyCharm with Anaconda Prompt this way, then execute them (e.g. «run.sh») on command line with

I tried putting this on the first line of my run.sh

But this had the effect of running it in an external Anaconda Prompt instance (add sleep, or some user input command to force it to wait and see for yourself). Explicitly running my .sh files with bash had the desired effect of running them in the same shell as I started them in PyCharm Terminal configured with Anaconda Prompt.

Источник

Command-line interface

Use PyCharm features from the command line: open files and projects, view diffs, merge files, apply code style, formatting, and inspect the source code.

For information about running command-line tools from inside PyCharm, see Terminal emulator.

Launcher for a standalone instance

The installation directory contains batch scripts and executables for launching PyCharm, formatting the source code, and running inspections. To use them from the Command Prompt cmd.exe , add the location of the PyCharm bin folder to the PATH environment variable. For example, if you installed PyCharm to C:\Program Files\JetBrains\PyCharm , you can use the following command:

This command changes the PATH environment variable for the current shell only (the current instance of cmd.exe ). If you want to update it permanently for the current user, run setx :

To update it system-wide for all users, run setx /M instead of setx .

The installer can do this for you if you select Add launchers dir to the PATH on the Installation Options step of the setup wizard.

After you configure the PATH variable, you can run the executable from any working directory in the Command Prompt: pycharm64.exe . Alternatively, you can use the batch script: pycharm.bat .

Читайте также:  C dll for linux

To run PyCharm from the shell, use the open command with the following options:

  • -a : specify the application.
  • —args : specify additional arguments when passing more than just the file or directory to open.
  • -n : open a new instance of the application even if one is already running.

For example, you can run PyCharm.app with the following command:

If PyCharm is not in the default /Applications directory, specify the full path to it.

You can create a shell script with this command in a directory from your PATH environment variable. For example, create the file /usr/local/bin/pycharm with the following contents:

Make sure you have permissions to execute the script and since /usr/local/bin should be in the PATH environment variable by default, you should be able to run pycharm from anywhere in the shell.

On Linux, the installation directory contains the launcher shell script pycharm.sh under bin . For example, if you installed PyCharm to /opt/pycharm , you can run the script using the following command:

You can create a symbolic link to the launcher script in a directory from the PATH environment variable. For example, if you installed PyCharm to /opt/pycharm and want to create a link named pycharm in /usr/local/bin , run the following command:

Since /usr/local/bin should be in the PATH environment variable by default, you should be able to run the pycharm command from anywhere in the shell.

If you installed PyCharm as a snap package, you can use the corresponding launcher: pycharm-professional or pycharm-community .

Shell scripts generated by the Toolbox App

If you are using the Toolbox App to install and manage JetBrains products, you can use shell scripts for launching your IDEs from the command line.

Toolbox App generates shell scripts automatically and places them to the following folders:

By default, the Toolbox App puts shell scripts in a directory from the system PATH environment variable, so you can run the name of the script as a command to launch PyCharm from any working directory.

Change shell scripts location

  1. Open the Toolbox App, click the Toolbox App menu icon in the top right corner, and select Settings . Toolbox App menu icon
  2. On the Settings tab, expand the Tools section, and specify another folder in the Shell scripts location field. Changing location of shell scripts

Rename shell scripts

If you have several versions of the same IDE, the Toolbox App generates a shell script for each version with a unique name. You can change the name of the shell script for an IDE instance in the settings for this specific instance.

Toolbox App PyCharm Settings

  1. Open the Toolbox App.
  2. Click next to an IDE instance and select Settings .
  3. At the bottom of the Configuration section, change the Shell script name field.

By default, the Toolbox App puts shell scripts in a directory from the system PATH environment variable, so you can run the name of the script as a command to launch PyCharm from any working directory.

Читайте также:  Вывод содержимое файла линукс

Change shell scripts location

  1. Open the Toolbox App, click the Toolbox App menu icon in the top right corner, and select Settings . Toolbox App menu icon
  2. On the Settings tab, expand the Tools section, and specify another folder in the Shell scripts location field. Changing location of shell scripts

Rename shell scripts

If you have several versions of the same IDE, the Toolbox App generates a shell script for each version with a unique name. You can change the name of the shell script for an IDE instance in the settings for this specific instance.

Toolbox App PyCharm Settings

  1. Open the Toolbox App.
  2. Click next to an IDE instance and select Settings .
  3. At the bottom of the Configuration section, change the Shell script name field.

By default, the Toolbox App puts shell scripts in a directory from the system PATH environment variable, so you can run the name of the script as a command to launch PyCharm from any working directory.

Change shell scripts location

  1. Open the Toolbox App, click the Toolbox App menu icon in the top right corner, and select Settings . Toolbox App menu icon
  2. On the Settings tab, expand the Tools section, and specify another folder in the Shell scripts location field. Changing location of shell scripts

Rename shell scripts

If you have several versions of the same IDE, the Toolbox App generates a shell script for each version with a unique name. You can change the name of the shell script for an IDE instance in the settings for this specific instance.

Toolbox App PyCharm Settings

  1. Open the Toolbox App.
  2. Click next to an IDE instance and select Settings .
  3. At the bottom of the Configuration section, change the Shell script name field.

Command-line arguments

The launcher script accepts commands, options, and other arguments to modify its behavior:

Without any arguments, the script launches PyCharm.

Path to file or directory

Open the file or directory specified as the argument.

Commands

Open the diff viewer to see the differences between two specified files.

Open the Merge dialog to merge the specified files.

Apply code style formatting to the specified files.

Perform code inspection on the specified project.

Options

Do not show the splash screen when loading PyCharm.

Do not reopen projects and show the welcome screen. This can help if a project that was open crashes PyCharm.

Do not load manually installed plugins. This can help if a plugin that you installed crashes PyCharm. You will be able to start the IDE and either disable or uninstall the problematic plugin.

Wait for the files to be closed before returning to the command prompt.

For example, you can open file.txt with the following command:

pycharm64.exe —wait file.txt

The shell will be waiting until file.txt is closed.

Источник

Оцените статью
Adblock
detector