Related
I installed pipenv by following the instructions here. From the Windows command prompt I ran
pip install --user pipenv
which returned the message
Successfully installed pipenv-5.3.3
Now I want to install the requests package using pipenv, so I ran
pipenv install requests
but this returned
'pipenv' is not recognized as an internal or external command,
operable program or batch file.
I have added the path
C:\Users\Robert\AppData\Roaming\Python\Python35\site-packages
to my Windows path environment variable, but I still receive the same error.
How can I install the requests package using pipenv?
EDIT: As I have remnants of Python 3.5 and Python 3.6 on my system, I'm going to uninstall everything and start anew. (I've just started learning Python and I want to keep this as simple as possible.)
I have a similar setup and faced a similar problem, but the solution I found was fairly simple. All of my PATH variables were already correct (from Python 3 the Windows Installer automatically does all of this).
The problem
The problem actually arises because of conflicting installations of virtualenv.
Fix
To address this problem you need to simply run the following commands:
First, remove your current version of virtualenv: pip uninstall virtualenv
Then, remove your current version of pipenv: pip uninstall pipenv
When you are asked Proceed (y/n)? just enter y. This will give you a clean slate.
Finally, you can once again install pipenv and its dependencies: pip install pipenv
This will also install the latest version of virtualenv.
Testing if it worked
Just enter pipenv --version in the command prompt and you should see the desired output.
Notes
I know this sounds the mundane, but it is actually the solution for Windows systems. You do not need to modify any of your system environment variables (please do not add site-packages to your environment variables).
python -m pipenv may work for you, (or python3 -m pipenv or py 3 -m pipenv) this is telling python to run the module pipenv instead of the terminal shortcut which sometimes doesn't install properly.
Just to show they are equivalent when I installed pipenv and run which pipenv it points to a file like /Library/Frameworks/Python.framework/Versions/3.6/bin/pipenv which looks like this:
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
# -*- coding: utf-8 -*-
import re
import sys
from pipenv import cli
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(cli())
so it removes .pyw or .exe from the executable name then call pipenv.cli.cli(). It is likely there is a file like this on your machine it just didn't add python's /bin folder to your system PATH so it isn't accessible, there is usually a warning when installing python if this happens but no one checks those. :P
the module pipenv.__main__ which is run when using python -m pipenv looks like this:
from .cli import cli
if __name__ == '__main__':
cli()
Which calls pipenv.cli.cli(). So this main module absolutely does the same effective thing.
to solve this problem i need to start my CMD as administrator.
pip uninstall pipenv
pip install pipenv
To test this new configuration, you can write pipenv --version
Use python -m pipenv instead of just pipenv, it should work. Best of luck to you.
Try adding the following to Path environmental variable:
C:\Users\Robert\AppData\Roaming\Python\Python36\Scripts
instead of the \site-package, as that is where pipenv.exe is installed (at least for me).
use this cmd solve my problem :
python -m pipenv install django==2.1
Many thanks to #Srivats Shankar. In case you have tried what he said and it did not work, hope you did not forget to check your python path? If you have more than a single python version installed, doing pip uninstall virtualenv or pip uninstall pipenv might not help solve the problem.
Every python version is generally supposed to have its own pip installed. What you would do in this case is:
`-python -version_to_uninstall_virtualenv_from -m pip uninstall virtualenv; py --version -m pip uninstall virtualenv
-python -version_to_uninstall_pipenv_from -m pip uninstall pipenv; py --version -m pip uninstall pipenv`
Then you install pipenv with a similar command:
`-python -version_to_install_pipenv_on -m pip install pipenv; py --version -m pip uninstall pipenv`
I had an error like you sed and I just reinstalled pipenv and it fixed.
I used this command:
pip install pipenv
Instead of
C:\Users\Robert\AppData\Roaming\Python\Python35\site-packages
it should be
C:\Users\Robert\AppData\Roaming\Python\Python36\Scripts
after that, try closing and reopening the terminal
check warnings after installing pipenv. sometimes pipenv location not registered in environment variables.
I noticed several different situations with multiple python versions installed.
A preferred solution would be to use:
python -m pip install pipenv
This command for Python3.7 instance generates executables in
C:\Users\XXX\AppData\Local\Programs\Python\Python37\Scripts and it made setting up other packages easier.
Windows is not officially supported, I think.
ref: https://github.com/kennethreitz/pipenv/issues/70
Please check that pipenv is installed in your system by run following command in command promt:
pipenv --version
If it returns error, so please install again and set environment variable path in your system
I'm trying to teach myself python, and I feel out of my depth. To start, I am working on a mac which already comes with python 2.7 installed.
I installed python 3.6 recently and have been using it to teach myself the basics. I'd like to eventually learn how to produce mathematical plots in python, and I know I will need the matplotlib package to do that.
Following some advice online, I was told that python3 already comes with pip installed, which is what I thought I should use to install matplotlib. The advice said I should type the following into the mac terminal:
python3.6 -m pip install matplotlib
I typed this, and it seemed like the package was installing, but I ended up getting some sort of error code that said:
Command "python setup.py egg_info" failed with error code 1 in [folder].
I tried opening IDLE and typing "import matplotlib", but I got the error: "no module named matplotlib". I also tried typing "import matplotlib.pyplot as plt", but I got the same error.
Based on further research and this youtube video, I've decided to just install miniconda in order to have access to the matplotlib package.
The problem is, I'm not sure if I should somehow be uninstalling whatever was installed when I ran the code above to install matplotlib. I've actually run that line of code 3 or 4 times. Should I remove anything before installing miniconda? Also, I am running python 3.6, while miniconda is listed on the website as being for python 3.5. Does this mean it won't work for my version of python?
Running pip like that would install packages system-wide. I'm guessing it's failing because you're not running as root (i.e. the administrator user). But wait! Don't try again as root! Instead of installing packages, do it in a virtual environment. First create it:
virtualenv myenv
This creates a directory called myenv with a bunch of stuff in it (so make note of where you run this command). Whenever you want to use the virtual environment (like straight away!) you first need to activate it:
. myenv/bin/activate
Don't miss out that dot (followed by a space) at the beginning! As the other answer says, the first thing you should do in it is upgrade pip:
pip install --upgrade pip
Now you're ready install whatever else you like:
pip install matplotlib
One last note: The virtual environment is tied to a particular Python version. By default it uses the system's Python 2.7 installation, so to use a different one you need to specify it when you create the virtual environment, like this (if that Python version is installed system-wide):
virtualenv -p python3.5 myenv
Or like this (if that Python version is not installed system-wide):
virtualenv -p /path/to/my/installation/of/python3.5 myenv
While the virtual environment is activated, you don't need to specify the particular path/version of Python. Just run it like this:
python
I also encountered many problems during my installation.
It seems that version 2 of matplotlib is not compatible with Python version 3.
Finally, I succeeded by specifying version 3 of matplotlib as follows with the following command:
sudo apt-get install python3-matplotlib
Reference from the Matplotlib website:
https://matplotlib.org/users/installing.html#building-on-linux
Try upgrade setup tools
--upgrade setuptools
or
easy_install -U setuptools
or upgrade pip
pip install --upgrade pip
I ended up downloading anaconda and using the python interpreter that comes with it, as anaconda comes with matplotlib and many other python packages of interest.
the pip command typically is for the Python 2. use pip3 instead to install the libraries in the python 3.X path
This should work
pip3 install matplotlib
The solution that work for me in python 3.6 is the following
py -m pip install matplotlib
Matplotlib files are downloaded in ~/.local/lib/python3.6/site-packages/ and not in /usr/lib/python3.6/ .
Try the command:
sudo cp -r ~/.local/lib/python3.6/site-packages/* /usr/lib/python3.6/
I try to use virtualenv inside a folder using the command virtualenv . and getting the error -bash: virtualenv: command not found. However, I installed virtualenv using pip pip installed virtualenv and also, upgraded it earlier with sudo pip install virtualenv.
How to use virtualenv properly ? I'm following a tutorial and they seems doing the same and gets away with it. I'm a Java developer with beginner knowledge of Python and working to improve it.
This is pretty simpleJust goto environment folder
Try: Scripts/activate
This will activate the environment
Try:Scripts/deactivate
This will deactivate current environment
After I installed Python and Djangom, I'm trying to use virtualenv for django project purpose using virtualenv. I installed virtualenv using pip.
pip install virtualenv # got install successfully
When I tried to run it, I got the error message
C:\Users\gshiv\Desktop\DjangoProject>virtualenv
'virtualenv' is not recognized as an internal or external command,
operable program or batch file.
steps:
- go to where you want create django app on that folder.
then run this command on command prompt : python -m virtualenv .
(eg. C:\Users\gshiv\Desktop\django>python -m virtualenv .)
where django is the my folder i want run virtualenv and .(dot) indicates virtualenv install all it's folder in django folder otherwise you can use other folder name instead .(dot) this time virtulenv creates a folder in main folder(django) .
after running this command: run .\scripts\activate now you can see this type of line on cmd-prompt (django) C:\Users\gshiv\Desktop\django>
i.e main folder name before the source path. now you can install any modules for your project that belongs to that main folder only.
pip install django works fine.
If you can not find your virtualenv command in the windows console/terminal after installing it with pip, try this to make your environment 🔽
python -m virtualenv <nameOfEnv>
If you want to use a specific version of python, initialize it like this 🔽
python -m virtualenv <nameOfEnv> -p=<C:/path/to/python/version3.x.x/python.exe>
When using windows for first installation, you can use python from WindowsApp
Run pip uninstall virtualenv and then pip install virtualenv
There are three points that you need to consider:
Make sure that in the windows PATH variable there is an entry with your python installation and the scripts subfolder eg: C:\Program Files (x86)\Python36-32\ and C:\Program Files (x86)\Python36-32\Scripts\
When using pip install virtualenv, make sure that you run cmd as administrator. Otherwise, there might an access denied error during installation and virtualenv will not be installed properly.
Make sure that virtualenv has been installed correctly. Check in the python scripts subfolder - there must exist an .exe named virtualenv.exe. If not, uninstall will pip uninstall virtualenv and install again.
When I ran the pip install virtualenv command I got:
Requirement already satisfied: virtualenv in c:\directory\to\appdata\roaming\python\python36\site-packages
so I tried forcing upgrade:
pip install --upgrade --force virtualenv
py -3 -m venv venv
try using the above command.
virtualenv venv
will work on only older version of python
Use
python -m venv abc
Where abc is the name of the virtual environment
Run CMD as administrator and then enter
pip uninstall virtualenv
then re-run CMD as administrator and run
pip install virtualenv
Step 1: Run pip uninstall virtualenv.
Step 2: Run pip install virtualenv.
Step 2.1: Run virtualenv to check if it's now working...
Step 3: Still not working? Go to your prevouis console log to find where it says "WARNING: The script virtualenv.exe is installed in
'C:\Users\username\AppData\Roaming\Python\Python310\Scripts' which
is not on PATH."
Step 4: Copy the specified path from the warning message.
Step 5: Search for and open "System Properties" on your PC.
Step 6: Click the Advance tab, and then the Environment Variables Button on the bottom right.
Step 7: Click the variable value "Path" and then click edit.
Step 8: In the Edit Environment variable window, click new then paste your path in any slot.
Step 9: MAKE SURE you click OK twice and not to just exit out.
Step 10: Reboot terminal and check again.
Use py -m virtualenv Your_Folder_Name
To install to a specific folder e.g E:\publish
pip install virtualenv
virtualenv .
Try to run
PowerShell.exe -command "./venv/Scripts/activate"
You just need to reinstall virtualenv. First of all you need to uninstall virtualenv with this command.
pip uninstall virtualenv
Then just reinstall with this command.
pip install virtualenv
Solution-1: python -m venv name_of_virtual_environment
E:\code\python\tvenv>python -m venv myenv
E:\code\python\tvenv>cd myenv\Scripts\
E:\code\python\tvenv\myenv\Scripts>activate.bat
(myenv) E:\code\python\tvenv\myenv\Scripts>deactivate.bat
E:\code\python\tvenv\myenv\Scripts>
Solution-2: py -3 -m venv name_of_virtual_environment
E:\code\python\tvenv>py -3 -m venv myenv
E:\code\python\tvenv>cd myenv\Scripts
E:\code\python\tvenv\myenv\Scripts>activate.bat
(myenv) E:\code\python\tvenv\myenv\Scripts>deactivate.bat
E:\code\python\tvenv\myenv\Scripts>
For windows
First, install -> pip install virtualenvwrapper-win
Then setup -> mkvirtualenv myproject
Then you see the list of virtual environment
To see it you write-> lsvirtualenv
For working this environment we write -> workon myproject
I had this same issue using python3.
The solution was to use the python3 -m virtualenv . command.
This almost works for all
Open Command Prompt, navigate it to the Envs folder, run "env_name\Scripts\activate"
Check whether virtualenv is installed or not, if not install it:
pip install virtualenv
pip install virtualenvwrapper-win
Game On. Check on your IDE.
Try executing virtualenv.exe from its absolute path, like in my case i found it in C:\Users\<your user>\AppData\Roaming\Python\Python37\Scripts\virtualenv.exe.
I tried this and it worked, here refer the logs as follows:
Using base prefix c:\\users\\<user>\\appdata\\local\\programs\\python\\python37-32
New python executable in C:\somedir\dir2\dir3\ML_1\ml\env\Scripts\python.exe
Installing setuptools, pip, wheel...
done.
I got this error too but I figure it out.
you just have to open PowerShell as administrator and then write following command Set-ExecutionPolicy unrestricted then type A. you are all set!
now uninstall the packages and re-install them.
Now if you write flask --version or virtualenv --version There will be no error at all.
Windows
If you want to use the lsvirtualenv command with virtualenv, follow the steps below.
Incorrect:
python -m pip install virtualenv
python -m pip install virtualenvwrapper
Correct:
python -m pip install virtualenv
python -m pip install virtualenvwrapper-win
Basic Uses
Then, to create a virtual environment:
mkvirtualenv youVirtualEnvironmentName
It will be activated automatically:
C:\Users\YourUserName (youVirtualEnvironmentName) λ
First, to access an existing virtual environment:
C:\Users\YourUserName λ workon youVirtualEnvironmentName
Next, to exit the currently active virtual environment:
C:\Users\YourUserName (youVirtualEnvironmentName) λ deactivate
Finally, to list all your virtual environments:
C:\Users\YourUserName λ lsvirtualenv
dir /b /ad 'C:\Users\YourUserName\Envs'
==================================================================
youVirtualEnvironmentName
Make sure that virtualenv has been installed correctly. Check in the python scripts subfolder - there must exist an .exe named virtualenv.exe. If not, uninstall will pip uninstall virtualenv and install again.
1)First Way as
python -m virtualenv name_of_virtual_environment
OR
2)Second Way as
py -3 -m venv name_of_virtual_environment
Open a cmd or ps with run as admin.
Now run pip uninstall virtual.
pip install virtual.
Done :D
Implementation:
Go to the directory where you want to make a python env.
type: virtualenv myEnv
beep bop boop done.
ps: Always use cmd or powershell with run as admin if you're installing some new package.
I am trying to create a virtual environment using virtualenv on Mac OS X El Capitan. I have installed Python 2.7.11 with brew, which includes pip, wheel and setuptools by default.
Hovewer, when I try to install virtualenv following instructions in the documentation or from any other resource, I get several problems:
virtualenv executable is not placed in /usr/local/bin after pip makes its job, so I need to ln -s it by hand (it may indicate, that there is something wrong with installation on this step).
After I run virtualenv venv, it creates new environment, catches Python 2.7.11 from brew-installation, but: there is no pip inside bin folder. That means, that if I try which pip, having venv activated, it returns a global position of pip — /usr/local/bin/pip, not /path/to/venv/bin/pip.
As a consequence, installing packages inside venv uses global pip and installs them to a global sites-packages, not that inside venv, and it's quite the opposite of what environment should do.
Could you please suggest what may be wrong and how to fix it?
EDIT: The thing to mention is that I used to have other versions of Python installed on my computer, which I have recently deleted as it is described in this answer. Maybe it causes the issue, and some more thorough cleaning is needed.
Try removing or renaming the .pydistutils.cfg file in your home directory, e.g. by renaming with mv ~/.pydistutils.cfg ~/oldpydistutils.cfg
I'm putting a detailed answer here to help others, but the original credit goes to this answer. If you know what specifically in .pydistutils.cfg was causing the problem, let me know!
I was having the same issue: my virtual environments were created without a local copy of pip, although they had a local copy of python. This meant that using $ pip from within the virtual environment installed to the global package location, and was not visible to the environment's python.
How I diagnosed this on my machine:
I create a virtualenvironment with $ virtualenv env
Activated the virtual environment with $ source env/bin/activate
Checked python location: run (env)$ which python with output /Users/<username>/env/bin/python (as expected)
Checked pip location: run (env)$ which pip with output /usr/local/bin/pip (NOT expected)
To check where our packages are going, we can try to install a package in the virtual environment:
Try to install a package: (env)$ pip install HTTPServer which succeeds
Try to run the package: (env)$ python -m HTTPServer which fails with error /Users/emunsing/env/bin/python: No module named HTTPServer
To double-check, try to install again: (env)$ pip install HTTPServer which produces Requirement already satisfied (use --upgrade to upgrade): HTTPServer in /usr/local/lib/python2.7/site-packages
Double-checking, we see that there's no Pip in the environment's /bin folder:
$ ls env/bin
activate activate.fish python python2
activate.csh activate_this.py python-config python2.7
And so while the system finds the local python version, it can't find a local pip to use and traverses the $PATH. It ended up using pip from /usr/local/bin, leaving me unable to install packages locally to the virtual environment.
Here's what I tried:
- Reinstalling python brew uninstall python followed by brew upgrade and brew install python --build-from-source
- Installing pip using the get-pip.py command as described in the Pip documentation
Here's what I ruled out:
- I was not using sudo pip ... which caused similar problems in this other question and haven't done so at any time on this Python/pip install
- My virtual environment didn't show a local installation of pip, as was the case in these similar questions: This one for Windows, This one for Mac OS X.
Ultimately, I found that eliminating the ~/.pydistutils.cfg file fixed the problem, allowing for fresh virtual environments that had their own local pip. The contents of my ~/.pydistutils.cfg file were:
[global]
verbose=1
[install]
install-scripts=$HOME/bin
[easy_install]
install-scripts=$HOME/bin
Simply renaming the ~/.pydistutils.cfg file appears to fix the problem: it seems that although this file was created by the homebrew installation, some settings in this file may be incompatible with virtualenv. While removing this file hasn't had any bad effects on my system, you may need to use the --user flag when installing packages with pip to the global environment (e.g. $ pip install --user HTTPServer). Here are more details on .pydistutils.cfg if you want to work on tailoring it for your needs.
virtualenv executable is not placed in /usr/local/bin after pip makes its job, so I need to ln -s it by hand (it may indicate, that there is something wrong with installation on this step).
Don't do that. That will only hide the bug and not solve the problem. Here's a short guide how to debug this kind of issues:
Start with which -a python. The first path you see should be /usr/local/bin/python, if not check your PATH variable.
Next, check which -a pip. Again the first path should be /usr/local/bin/pip. If not, run python -m ensurepip and recheck.
Now install virtualenv using pip install virtualenv, after that check the output of which -a virtualenv. The first path should be /usr/local/bin/virtualenv, if not check the output of env |grep PYTHON for unexpected environment variables.
Finally check the output of virtualenv --version to make sure you have the latest version.
I had the issue when running virtualenv: "ImportError: No module named pip."
My solution was to downgrade virtualenv. I had 16.2.0.
pip uninstall virtualenv
pip install virtualenv==15.1.0
Just hit same issue on Linux. Seems like there are multiple causes of this issue, but for me answer was to remove ~/.pip/.
Details: I had this in my .pip/pip.conf for some reason I can't remember:
$ cat ~/.pip/pip.conf
[global]
use_https = True
index = https://pypi.python.org/pypi
prefix = /home/sam/local/
and was using local versions on Python, Pip installed at ~/local/. For some reason virtualenv installed pip must pick up prefix = /home/sam/local/ setting and pip was being installed there.
Try this: sudo apt install pythonV.v-distutils.
In my case V.v == 3.8.
This worked for me.