i use python 2.7.10 and window 7. When i use "pip" to install new package, i don't see anything when it run like this:
install pillow using pip
Can anybody tell me how to fix it?
PIP uses a configuration file called pip.ini, in which you can set default command-line options for PIP. Chances are the --quiet option is turned on by default; this option causes PIP to produce no output unless there's an error, just like in your case.
There are multiple places that it could be:
C:\Users\you\AppData\Roaming\pip\pip.ini
C:\ProgramData\pip\pip.ini
You need to edit your file (if they're both present, edit both) to remove the lines that look like one of the following:
quiet = true / on / yes
q = true / on / yes
Save the file(s) and you should then see output from PIP the next time you run it.
If there's no pip.ini
If you can't find a pip.ini file anywhere, create one in:
C:\Users\you\AppData\Roaming\pip\pip.ini
Open it using a text editor, then put this inside it:
[global]
quiet = false
Demonstration
Here's a GIF demonstrating the difference between --quiet and no --quiet:
Related
Note: A previous question was closed because it needed to be more "focused", so I deleted the old one and modified the question so it only focus on VIM for Python.
I want to start using VIM but I´m having a hard time configuring it.
First, I did :syntax on to add some color to the syntax. Then, I wanted to change the version of Python that VIM is "verifying" as default (version 2+) to the recent version (3+) and did (something I found online) :let g:syntastic_python_python_exec = 'python3'. After I did this, the :syntax on stopped working (no more syntax highlighting) and VIM still didn´t support python3. What I mean is that if I write in Python3 I get error because it doesn't recognize version 3+
I´m using VIM (version 8+) from Terminal on Mac High Sierra.
Question:
How can I configure VIM to work with Python ? - to work with recent version of Python(3+), have syntax highlight ON and have a "file tree".
Please, answer as simply as possible so anyone who is new to VIM can understand. I searched a lot and the answers I found were old and confusing to understand for someone who is new to VIM and wants to start with it.
For the file tree, I would suggest the NerdTree plugin.
As for your syntax checker not working, I suggest you first create a Python 3 virtual environment via Pipenv, then open your vim within that virtual environment. That might solve your problem. You should always be using a virtual environment in any case if you are writing Python code.
I would suggest using coc.nvim. It is not entirely simple, but it is the simplest I know after trying a few alternatives.
Here is a relatively simple guide:
First install vim-plug: In your terminal, enter
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Then install coc.nvim:
This plugin requires nodejs,
curl -sL install-node.now.sh/lts | bash
Now put this code in your ~/.vimrc
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
Restart Vim, and type :PlugInstall and press enter. This will install the plugin for you.
Copy the default example vim configuration to the end of your ~/.vimrc (or anywhere after the plug#end()).
Inside vim, issue the command :CocInstall coc-python. This will install coc-python, which is their python support.
Inside vim, issue the command :CocConfig. This will open up a file coc-settings.json. Put in the following code in the file to use MS's Python language server.
{
"python.jediEnabled": false
}
Note that you can use jedi as well. I'm opting for MS because it's simpler to setup.
Restart vim and open a .py file. It will take a moment to install MS Python language server. After that, you should get syntax analysis and code completion.
To select an interpreter (python3), do :CocCommand, and you should see an option to set the interpreter. For virtual environments to show up, you can activate the virtual env in the command line before starting vim.
This question already has an answer here:
Can't import module when using root user [duplicate]
(1 answer)
Closed 2 years ago.
I am using keyboard library that`s need acces to sudo but when I try to run the program with sudo python dont find the others libraries
import pyautogui
import keyboard
if keyboard.is_preseed('w'):
....
So when I use without sudo keyboard dont work and when I use with sudo python dont find the others libraries
'sudo' sets up a new environment because it aims to be safe and because the new user won't have the same view of the world as you have.
You can use the keep-environment parameter to 'sudo' to preserve some of them, but that won't guarantee that your view is the same. It could be a permissions problem, or a relative path problem or a difference in homes, or a user shell-initialization setting in the other user. You can likely fabricate a good environment on the other side of sudo with something like "sudo env PYTHONSOMETHING=$PYTHONSOMETHING programname" .
So, it's complicated. I'd first use "sudo -i" to get an interactive shell and test what it looks like, and find what to change.
Python uses a different package insallation directory for each user by default.
For example, you can find the location of the keyboard package like so:
>>> import keyboard
>>> keyboard.__file__
'/home/user/.local/lib/python3.8/site-packages/keyboard/__init__.py'
As you can see, it is located in /home/user, which means only user is supposed to use it.
In order to install the package for the root user, just run pip with sudo:
sudo pip3 install keyboard
I am trying to use sunnyportal-py. Relatively new to python, I do not understand step 2 in the README:
How to run
Clone or download the repository.
Enter the directory and run:
PYTHONPATH=. ./bin/sunnyportal2pvoutput --dry-run sunnyportal.config
Enter the requested information and verify that the script is able to connect to Sunny Portal.
The information is saved in sunnyportal.config and can be edited/deleted if you misstype anything.
Once it works, replace --dry-run with e.g. --output to upload the last seven days output data to pvoutput or --status to upload data for the current day.
Add --quiet to silence the output.
Could anyone help me? I have gone into a cmd.exe in the folder I have downloaded, I don't know how to correctly write the python path in the correct location. What should I paste into the command line? Thanks!
Edit : I would like to be able to do this on Windows, do tell me if this is possible.
The command at bullet 2 is to be typed at the commandline (You need to be in windows: cmd or powershell, Linux: bash, etc.. to be able to do this).
PYTHONPATH=. ./bin/sunnyportal2pvoutput --dry-run sunnyportal.config
The first part of the command code above indicates where your program is located. Go to the specific folder via commandline (windows: cd:... ; where .. is your foldername) and type the command.
The second part is the command to be executed. Its behind the "--" dashes. The program knows what to do. In this case:
--dry-run sunnyportal.config
running a validation/config file to see if the program code itself works; as indicated by "dry run".
In your case type at the location (while in cmd):
"sunnyportal2pvoutput --dry-run sunnyportal.config"
or
"sunnyportal2pvoutput.py --dry-run sunnyportal.config" (without the environment variables (python path) set).
Note: the pythonpath is an environment variable. This can be added via: Control Panel\All Control Panel Items\System\ --> bullet Advanced System Settings --> button "environment variables". Then you can select to add it to "Variables for user "username"" or "system variables". Remember to reboot thereafter to make the change effective immediately.
Update 1 (pip install sunnyportal):
go to cmd.
type "pip search sunnyportal"
Result:
Microsoft Windows [Version 10.0.18363.836] (c) 2019 Microsoft
Corporation. All rights reserved.
C:\Windows\System32>pip search
sunnyportal
sunnyportal-py (0.0.4) - A Python client for SMA sunny portal
C:\Windows\System32>
If found, then type:
"pip install sunnyportal"
So I uninstalled Enthought Canopy (I think completely, but I'm unsure if there's residual information hanging around that I neglected to modify).
After uninstalling, following the directions here: https://support.enthought.com/entries/23580651-Uninstalling-and-resetting-Canopy
I was slightly unsettled by the fact that I couldn't find anything to delete for step 5, and since Canopy was never my default Python environment, I didn't think too much of it.
But now, every time I open terminal, I get this warning:
"-bash: /Users/MyName/Library/Enthought/Canopy_64bit/User/bin/activate: No such file or directory"
What do I need to do to fix this? I'm running Mac OSX, 10.8.5 (Mountain Lion). Any help would be much appreciated.
Until today I had this exact same problem, and it really bothered me. I solved it this way:
First, I entered following command in the terminal: open -a TextEdit .bash_profile
This opens your .bash_profile in TextEdit, which for a terminal novice like me at least, is easier than editing it in the terminal with vi or something like that. In that file, you should see a few lines related to "Canopy" and "Enthought". In my case, this is what showed up:
# Added by Canopy installer on 2014-02-11
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make bashprompt show that Canopy is active, otherwise 1
VIRTUAL_ENV_DISABLE_PROMPT=1 source /Users/MyUserame/Library/Enthought/Canopy_64bit/User/bin/activate
I think it is that last line that is causing all the trouble. Simply delete these few lines (don't delete anything else). In my case, these lines were in a separate block from others in my .bash_profile so it was easy to pick them out. After this, just close the text file, restart your computer, and the annoying stuff about Enthought not being found should be gone. For me this worked, hope it does for you too!
To find out where this is, run an interactive shell with the xtracefd flag set and a PS4 that includes $BASH_SOURCE. For instance:
PS4='+$BASH_SOURCE:$LINENO:' bash -i -x
Then, look through the output for the first reference to the activate script given; it will include the source file and line number.
Most likely, this will be .bashrc.
For anyone who is having this problem as I did, I found the source in my .profile file. You will see a command at the top of your .bash_profile or .bashrc that reads: [[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile. This is calling yet another script called .profile that you need to clean up. To edit .profile use the command:
open -a TextEdit .profile
Then you'll find a line in there that says something like:
# Added by Canopy installer on 2013-04-10
source /Users/username/Library/Enthought/Canopy_64bit/User/bin/activate
Delete those lines and save, et voila!
I had a similar error message. You need to comment out (#) or delete the last line thats under the #Canopy settings in your bash profile. follow below steps in terminal to get rid of the error message:
vim .profile
You should see the following info regarding your Canopy set up:
# Added by Canopy installer on 2016-01-12
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make bashprompt show that Canopy is active, otherwise 1
VIRTUAL_ENV_DISABLE_PROMPT=1 source '/Users/waismoradi/Documents/CanopyEnthought/User/bin/activate'
Just delete or comment out with -> # the last line and you are all set! This will disable the env prompt to show up when you launch terminal.
I'm writing a Mercurial extension in Python and need to call the "Pull" command using the Mercurial API, but I want to suppress its output using the --quiet flag.
In Hg terms, I want to execute the following code, but from within my extension:
hg pull --quiet
Given the Mercurial API documentation, I thought it would be as simple as:
commands.pull(ui, repo, quiet=True)
Unfortunately, although this doesn't generate errors and will successfully execute the "Pull" command, the --quiet flag doesn't seem to be getting through as I still see the standard output.
All the examples only show passing non-global flags, so I'm a bit worried that this isn't possible.
What am I doing wrong? How can I pass the --quiet flag?
Global options are affected through the ui object. It allows you to control many of the things you would normally set in your (or the repository's) hgrc. In this case, you want to set the quiet option in the ui section to True.
ui.setconfig('ui', 'quiet', True)
commands.pull(ui, repo)