I am learning Django (using version 1.4.5, bitnami stack) and Python (2.7.3) and trying to use virtualenv (version 1.8.4) for the first time. I have already installed virtualenv using pip and it seemed to install fine. However, when I try to create a new virtualenv environment, I seem to run into problems. Here's the errors I'm getting:
Attempt 1:
$ python virtualenv.py ENV
/Applications/djangostack-1.4.5-0/python/bin/.python2.7.bin: can't open file 'virtualenv.py'
[Errno 2] No such file or directory.
Attempt 2:
$ virtualenv venv --distribute
dyld: Library not loaded: /bitnami/djangostack-osx-x64/output/python/lib/libpython2.7.dylib
Referenced from: /Applications/djangostack-1.4.5-0/python/bin/.python2.7.bin
Reason: image not found
Trace/BPT trap
I searched for virtualenv.py and found that it is located at:
/Applications/djangostack-1.4.5-0/python/lib/python2.7/site-packages/
Attempt 3: I can cd to this folder from the command line and run the following command to create a new environment in the myproject_dir folder:
$ python virtualenv.py myproject_dir
Unlike Attempts 1 and 2, Attempt 3 actually seems to work, but it is not optimal. So, my conclusion is that somehow for the commands in Attempts 1 and 2, the system is looking in the wrong place. My sense is that a setting needs to be changed somewhere to point to the correct location of the virtualenv.py file, but I'm not sure where to look and how to actually make the changes? I've looked at other explanations on this site and Google, but still am not sure whether my diagnosis of the problem is correct and how to actually fix the problem.
Attempt one, don't do that, do this:
virtualenv ENV
attempt two indicates that you have your python paths muddled up as #Thai Trans says. I would make sure that you're calling the correct python from virtualenv
virtualenv -p /path/to/bitnami/python ENV
and not worry about the --distribute flag until you've got your regular virtualenv working.
Related
I have absolute no further idea, how i could manage the installation of the epftoolbox in python. I have tried the steps from https://epftoolbox.readthedocs.io/en/latest/modules/started.html in various ways and directions, but it still doesn't work and i get the following error when running the file:
ModuleNotFoundError: No module named 'epftoolbox.evaluation'
Can anyone suggest a step by step video or something like that, where the installation is showed for 'dummies'?
Any help would be veeeeery appreciated!
PS: I'm working with pycharm
Since you're working with pycharm first create a new project with a virtual environment and open the terminal and type the following clone statement : git clone https://github.com/jeslago/epftoolbox.git
then move to the cloned directory by typing this command:
cd epftoolbox
once your'e inside this directory run your pip install command:
pip install .
you should be able to work with the library here.
since you already created the virtual environment..
Hope it solved your problem.
I want to use python 2.7 instead of python 3, which is used by default (note that I have them both installed on my computer already).
So I tried what I saw should be the right thing to do, that is:
python -m virtualenv my_env -p "\Program Files (x86)\Python27\pythonw.exe"
and I receive the following message:
Running virtualenv with interpreter \Program Files (x86)\Python27\pythonw.exe
That doesn't look so much like an error to me, but yet, no environment is created. Can someone help me with that?
So yesterday I had to create a virtualenv in order to be able to install Python modules that wouldn't install thanks to OS X El Capitan's new SIP. I thought I did everything right, but today I'm reaching a different conclusion. I hope I can be clear about it.
my python custom install is at myname/learnp/imdb_module, this is where I created it with virtualenv. Edit: I later moved it to myname/learnp/ayr2/imdb_module.
However, when I try to run the interpreter, it seems to always default to the Python that is in Library or something along these lines. I found out about this because a certain module that I managed to install in this custom python env wouldn't import, when I checked what modules I have, it wasn't the same as what I expected.
Furthermore, it seems that ALL other modules that I wanted to install on the CUSTOM virtualenv were installed on the main python env, and that I wasn't installing those modules on the custom env all along.
Excuse me, but I'm very confused right now.
I know how to create a virtual env
I know how to activate it (it appears to the right on Terminal line)
I don't know how to install modules to my virtual env
I don't know how to make the interpreter run from the virtual env so I can do python operations that are only possible by using custom env modules
Any advice is much appreciated!
Update:
Followed Will Hogan's answer for troubleshooting,and I think something weird is happening, quoting my comment to his answer:
HI, thanks for taking the time to answer. This is basically the way I understood this. However, let me attach a screenshot: http://i.imgur.com/DfpngJq.jpg . Am I right to assume something is wrong here? My prompt is changed with the virtualenv named "imdb_module", but when I type in which python it doesn't list ayr2/imdb_module/bin but rather a folder with the path usr/bin/python, which if I understand correctly is the "default" environment.
And not if this helps in any way, but echo $PATH when (imdv_module) appears to the right of the prompt, gives this (I redacted my name): /Users/REDACTEDNAME/learnp/imdb_module/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
While creating the virtualenv you should see it installing setuptools and pip:
$ virtualenv testvenv
New python executable in testvenv/bin/python2.7
Also creating executable in testvenv/bin/python
Installing setuptools, pip...done.
After ensuring the virtualenv is activated you should see your prompt change:
$ . ./testvenv/bin/activate
(testvenv)$
Now you can confirm the paths to python and pip, which should be in the virtualenv:
(testvenv)$ which python
/private/tmp/testvenv/bin/python
(testvenv)$ which pip
/private/tmp/testvenv/bin/pip
If you aren't seeing the python and pip locations as being under the virtualenv's directory, then the virtualenv has not been activated.
I would also ensure that, if you're executing the .py file directly (and not with "python foo.py"), that your shebang line uses:
#!/usr/bin/env python
Or even the full path to the virtualenv's python, e.g.:
#!/tmp/testvenv/bin/python
As opposed to, say:
#!/usr/bin/python
The first will search in the current environment, which will be set by the virtualenv activation. The second explicitly points to the virtualenv's `python'.
I've got myself in a pickle and would like some guidance before my laptop suffers GBH.
I have been using my Macbook for a few years without probs but when I got a new iMac at work I noticed everyone recommended useing homebrew for new Python installs (esp. on Mavericks).
Now my laptop has worked fine with the original Python. But I decided to try and do it the new homebrew way (its now Mavericks btw).
First I clear out Mavericks due to some other conflict then reinstall a fresh. Get nginx, php-fpm, mysql, etc working.
Now Python.
I can use pip to install packages. But when I try
workon myproject
I get:
/usr/bin/python: No module named virtualenvwrapper
/usr/bin/python: No module named virtualenvwrapper
But then it switches to that virtualenv anyway - but not the directory that the project is in!
When I run where python I get several entries:
/usr/local/bin/python
/usr/bin/python
/usr/local/bin/python
I've tried fiddling with my path but keep getting other errors that all seem to indicate my two Python installations are conflicting badly. Is there a simple solution or do I need to wipe out hombrew and start again from the beginning? Or just give up on homebrew and use OSX built in?
To clarify my current $PATH is:
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/go/bin:/Users/me/Development/Android/sdk/tools:/Users/me/Development/Android/sdk/platform-tools
My solution was an unusual one but here goes:
In my .zshrc file I had the following layout:
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="steeef"
plugins=(osx virtualenv virtualenvwrapper python github)
source $ZSH/oh-my-zsh.sh
# various aliases
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
The problem was the Oh My ZSH plugin virtualenvwrapper was looking in the default python path location as the custom path had yet to be set later in the .zshrc file.
The solution therefore was to move the PATH declaration before the plugins like so:
ZSH_THEME="steeef"
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
plugins=(osx virtualenv virtualenvwrapper python github)
source $ZSH/oh-my-zsh.sh
# various aliases
Now the ZSH plugins are referencing the correct Python install and therefore the correct Python packages path.
Try putting your preferred version earlier in your PATH variable. So if you want to use /usr/local/bin/python, from the command line you could modify your PATH by export PATH=/usr/local/bin/python:$PATH. See here for more info: http://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/
I am trying to create a Virtual Environment for my django site.
Command is below. but it says "You must provide a DEST_DIR" though I have given the directory name "SOWL".
virtualenv.py SOWL --no-site-packages
http://screencast.com/t/rej893zrg
I have spent half a day on this. I can't find anything on google search either.
Any help is much appreciated.
Thanks,
SHM
At first glance your command is out of order; the flags come first, directory last. However it doesn't seem to matter; the command, as you ran it, works for me on Mac and Windows.
I'd guess the problem lies with your installation of virtualenv. Virtualenv is also one of those tools that never seems to get updated. Make sure you have the latest. Install with pip (first choice) or if you need the actual virtualenv.py file, either way the instructions are here.
UPDATE Here's an install-Python-in-Windows guide. I know you already have Python, but this will make sure your PATH is setup and get you PIP and Virtualenv as well.
Install Python using the Windows installer
Add this to your PATH environment variable: C:\Python27\;C:\Python27\Scripts\
Get Distribute by downloading the distribute_setup.py file. (There is no Windows installer; the script does it all.)
Get PIP by downloading the get-pip.py file.
python distribute_setup.py
python get-pip.py
pip install virtualenv
Now you are set with virtualenv. However there's more — the virtualenvwrapper makes life easy. It's only for bash shells, but there's a Windows port here. There are installation instructions, tips and a rundown of the nifty new commands that the wrapper gives you.
pip install virtualenvwrapper-win
pyassoc
Create a new environment variable: WORKON_HOME=%USERPROFILE%\Envs
Now you can do this to create your virtualenv (and notice the prompt change to indicate which env you are in):
mkvirtualenv --distribute SOWL
>>>(SOWL) C:\Users\User>
I think your parameters are just out of order. Did you try
virtualenv.py --no-site-packages SOWL