Python and pip work just fine in PowerShell, but it's different if I run it while activating virtualenv. I got these errors:
(<project_name>-env) PS D:\Kerja\HIT\Python Projects\<project_name>\<project_name>-env\Scripts> python
Traceback (most recent call last):
File "D:\Kerja\HIT\Python Projects\<project_name>\<project_name>-env\lib\site.py", line 703, in <module>
main()
File "D:\Kerja\HIT\Python Projects\<project_name>\<project_name>-env\lib\site.py", line 692, in main
aliasmbcs()
File "D:\Kerja\HIT\Python Projects\<project_name>\<project_name>-env\lib\site.py", line 515, in aliasmbcs
import locale, codecs
File "D:\Kerja\HIT\Python Projects\<project_name>\<project_name>-env\lib\locale.py", line 17, in <module>
import functools
ImportError: No module named functools
(<project_name>-env) PS D:\Kerja\HIT\Python Projects\<project_name>\<project_name>-env\Scripts> pip
Fatal error in launcher: Unable to create process using '"'
How can I run python and pip successfully in virtualenv while using PowerShell?
I found the answer! It turns out when I use virtualenv on PowerShell, it prioritizes using python and pip from the virtualenv over the PATH environment variable.
The python and pip I mentioned before are located on /<environment_name/Scripts/> folder, along with activate and deactivate script. Deleting python.exe and pip.exe or just simply rename it will do.
Please note, it may affect pip freeze -l. I am not sure though.
Related
The problem is:
I cannot launch applications like Spyder, Glueviz, Jupyter Notebook and JupyterLab from Anaconda.
I however can launch VS code but I suspect this is because I already had it previously installed.
However typing "jupyter notebook" or "jupyter lab" on the windows command prompt would launch it well, but this is not using Anaconda. I think this is because I have previously installed jupyter using pip.
First time I installed Anaconda, I checked the add to path option and a while later I had to uninstall it because I couldn't run python applications outside of anaconda. I checked my environment path variables and there are no references to Anaconda in it. So I guess this solution is out of the way.
This time when installing Anaconda, I made sure not to check the add to path option.
Sometimes, I would think this is an installation error, let's uninstall it then reinstall it, but that didn't work. I am using a freshly installed version of Anaconda now and the problem is persisting.
Here is an error that displays when I try to launch Spyder
Traceback (most recent call last):
File "C:\Users\saife\anaconda3\Scripts\spyder-script.py", line 6, in
from spyder.app.start import main
File "C:\Users\saife\anaconda3\lib\site-packages\spyder\app\start.py", line 22, in
import zmq
File "C:\Users\saife\AppData\Roaming\Python\Python37\site-packages\zmq\__init__.py", line 47, in
from zmq import backend
File "C:\Users\saife\AppData\Roaming\Python\Python37\site-packages\zmq\backend\__init__.py", line 40, in
reraise(*exc_info)
File "C:\Users\saife\AppData\Roaming\Python\Python37\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\saife\AppData\Roaming\Python\Python37\site-packages\zmq\backend\__init__.py", line 27, in
_ns = select_backend(first)
File "C:\Users\saife\AppData\Roaming\Python\Python37\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\saife\AppData\Roaming\Python\Python37\site-packages\zmq\backend\cython\__init__.py", line 6, in
from . import (constants, error, message, context,
ImportError: cannot import name 'constants' from 'zmq.backend.cython' (C:\Users\saife\AppData\Roaming\Python\Python37\site-packages\zmq\backend\cython\__init__.py)
Try this instead of pip, conda install -c anaconda "IDE you want"
I followed djangogirls tutorial to get started with django and had everything working. Once I finished the basic tutorial, everything in working order, I decided to go through the steps again to make something new and become more familiar with using git, django, venv, etc.
fyi - I am on windows 10 and have python 2.7 and python 3.5 installed. I am using python 3.5.2 with django 1.10.4.
steps:
>mkdir v2
>cd v2
>"d:/python 3.5.2/python" -m venv myenv
>cd myenv/scripts/activate
(myenv) python -m pip install -U pip
for some reason this is the only way I was able to upgrade pip this time around
(myenv) d:/v2/myenv/scripts> pip install django~=1.10.0
(myenv) d:/v2/myenv/scripts> django-admin.py startproject mysite
This is where the magic doesn't happen:
d:\v2>django-admin.py startproject mysite2
Traceback (most recent call last):
File "D:\v3\myenv\Scripts\django-admin.py", line 2, in <module>
from django.core import management
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 10, in <module>
from django.apps import apps
File "C:\Python27\lib\site-packages\django\apps\__init__.py", line 1, in <module>
from .config import AppConfig
File "C:\Python27\lib\site-packages\django\apps\config.py", line 4, in <module>
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
File "C:\Python27\lib\site-packages\django\core\exceptions.py", line 5, in <module>
from django.utils.encoding import force_text
File "C:\Python27\lib\site-packages\django\utils\encoding.py", line 11, in <module>
from django.utils.six.moves.urllib.parse import quote, unquote
File "C:\Python27\lib\site-packages\django\utils\six.py", line 92, in __get__
result = self._resolve()
File "C:\Python27\lib\site-packages\django\utils\six.py", line 160, in _resolve
module = _import_module(self.mod)
File "C:\Python27\lib\site-packages\django\utils\six.py", line 82, in _import_module
__import__(name)
File "C:\Python27\lib\urllib.py", line 26, in <module>
import socket
File "C:\Python27\lib\socket.py", line 47, in <module>
import _socket
ImportError: Module use of python35.dll conflicts with this version of Python.
As far as I am aware, I followed the same steps. I am not sure why the djano installed in my venv would be referencing python 2.7, since I thought if created my venv from the python 3.5.2 dir it would reference that version, along with anything I used pip for within that dir?
Can someone help me find what I am missing here? ty.
By default virtualenv uses python2. If you want to use python3, you have to specify it explicitly.
Run following command to setup virtualenv with python3:
virtualenv -p python3 envname
While in "Python 3.5.2/scripts" I ran:
virtualenv d:/<dirname>
Everything after(django-admin.py startproject projectname) worked correctly. Still not sure what went wrong here but maybe this helps someone else...
The situation: I'm trying to install pyside on a project using the PyCharm IDE, however it says that it does not support python 3.5 that is installed by default on ubuntu 16.04. It does support python 2.7, however I'd rather not start a new project using python 2.
What I've done:
So I download python 3.45, extracted it, and I am successful in installing it to a directory using the following command:
`cd /path/to/extracted/python34
./configure --prefix=/path/to/install/dir
make
make install`
The next step is to create a virtualenv out of the newly installed python 3.4, so that it will have its own pip and other tools, so I run the following code:
cd /path/to/virtualenv/script
./virtualenv.py --python=/path/to/python34 /path/to/desired/virtualenv/dir
which fails, unfortunately
What went wrong:
I attempt to use the newly installed Python 3.4 to create a virtualenv, however I am met with errors when I do so. The result is the same whether I create the virtualenv using the builtin PyCharm tool, or even if I use a downloaded source of the virtualenv script. However, I was able to find out that the first error was about zlib, and I attempted to apply the solutions found here: building Python from source with zlib support
The zlib issue was resolved by logging in as administrator, and installing zlib1g-dev through:
sudo apt-get install zlib1g-dev
I also uncommented the following line from the Modules/Setup file of the extracted Python 3.4 source
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
But even with the zlib issue resolved, I am now met with the following error log when trying to create a virtualenv using the freshly installed python 3.4:
`
Installing setuptools, pip, wheel...
Complete output from command /home/work/Documents...gQtEnv/bin/python3.4 - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/home/work/Documents/programming/tools/virtualenv-15.0.3/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/__init__.py", line 16, in <module>
File "/home/work/Documents/programming/tools/virtualenv-15.0.3/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/vcs/subversion.py", line 9, in <module>
File "/home/work/Documents/programming/tools/virtualenv-15.0.3/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/index.py", line 30, in <module>
File "/home/work/Documents/programming/tools/virtualenv-15.0.3/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/wheel.py", line 39, in <module>
File "/home/work/Documents/programming/tools/virtualenv-15.0.3/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 14, in <module>
File "/home/work/Documents/programming/tools/virtualenv-15.0.3/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/_vendor/distlib/compat.py", line 66, in <module>
ImportError: cannot import name 'HTTPSHandler'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "./virtualenv.py", line 2327, in <module>
main()
File "./virtualenv.py", line 711, in main
symlink=options.symlink)
File "./virtualenv.py", line 944, in create_environment
download=download,
File "./virtualenv.py", line 900, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "./virtualenv.py", line 795, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/work/Documents...gQtEnv/bin/python3.4 - setuptools pip wheel failed with error code 1`
What I'm trying to figure out:
And this is where I am now. I would like to create a virtualenv from a non-root and non-system installation of python that is built from source. I understand that I can fiddle around and do trial and error installation of what I would guess to be necessary packages until all the errors go away, however I am not keen on willy nilly installation, especially as root. I'm supposing that there must be a way to install python without root access, and create a virtual env using this. Maybe identify what the necessary packages are, download all of them, build them, and add them to my local user's system path? Unfortunately I only have a vague idea on how to do half of these. Any guidance will be appreciated.
Thanks to all those who have taken time to read this and have attempted to provide a solution. Hoping for a resolution to the issue.
I've recently just installed Anaconda 3 (for Python 3.4) on a fresh Ubuntu 14.04 installation.
When I go to launch the spyder IDE, I receive following error message:
No module named 'version'
Traceback (most recent call last):
File "/home/daniel/anaconda3/bin/spyder", line 3, in <module>
start_app.main()
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/start_app.py", line 91, in main
from spyderlib import spyder
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/spyder.py", line 158, in <module>
from spyderlib.utils.environ import WinUserEnvDialog
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/utils/environ.py", line 17, in <module>
from spyderlib.widgets.dicteditor import DictEditor
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/widgets/dicteditor.py", line 28, in <module>
from spyderlib.utils.qthelpers import mimedata2url
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/utils/qthelpers.py", line 24, in <module>
from spyderlib.guiconfig import get_shortcut
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/guiconfig.py", line 24, in <module>
from spyderlib.widgets.sourcecode import syntaxhighlighters as sh
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/widgets/sourcecode/syntaxhighlighters.py", line 32, in <module>
required_version=PYGMENTS_REQVER)
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/dependencies.py", line 70, in add
installed_version)]
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/dependencies.py", line 32, in __init__
self.installed_version = programs.get_module_version(modname)
File "/home/daniel/anaconda3/lib/python3.4/site-packages/spyderlib/utils/programs.py", line 218, in get_module_version
mod = __import__(module_name)
File "/home/daniel/qiime_software/sphinx-1.0.4-release/lib/python2.7/site-packages/Pygments-1.6-py2.7.egg/pygments/init.py", line 46
except TypeError, err:
^
SyntaxError: invalid syntax
I installed Conda 3.7 by downloading the .sh file through http://continuum.io/downloads#py34 and then installing it through the terminal with "bash Anaconda3-2.1.0-Linux-x86_64.sh"
What could be the issue?
I may have spotted the issue but still need some help:
When I first made this Ubuntu installation, I put QIIME on here (which is a suite of programs that have been made to work in their own environment for bioinformatics).
I see that in the list of file calls, everything is coming from .../anaconda3/... until the very last line, something is mistakenly (?) called from .../qiime_software/...
I'm assuming this is from both software suites containing python in their PATHs... how may this be fixed? Granted when I check "which python" in the terminal, it (correctly) outputs:
/home/daniel/anaconda3/bin/python
I almost thought a prior question asked here: Anaconda Spyder Qt library error on launch would lead me on the right path but I hit a deadend.
Update:
echo $PYTHONPATH spits out:
/home/daniel/qiime_software/qiime-galaxy-0.0.1-repository-c2814c3c/lib/:/home/daniel/qiime_software/qiime-1.8.0-release/lib/python2.7/site-packages:/home/daniel/qiime_software/qiime-1.8.0-release/lib/:/home/daniel/qiime_software/matplotlib-1.3.1-release/lib/python2.7/site-packages:/home/daniel/qiime_software/pprospector-1.0.1-release/lib/python2.7/site-packages:/home/daniel/qiime_software/tax2tree-1.0-release/lib/python2.7/site-packages:/home/daniel/qiime_software/pynast-1.2.2-release/lib/python2.7/site-packages:/home/daniel/qiime_software/emperor-0.9.3-release/lib/python2.7/site-packages:/home/daniel/qiime_software/pycogent-1.5.3-release/lib/python2.7/site-packages:/home/daniel/qiime_software/biom-format-1.3.1-release/lib/python2.7/site-packages:/home/daniel/qiime_software/ipython-latest-repository-184467d4/lib/python2.7/site-packages:/home/daniel/qiime_software/sphinx-1.0.4-release/lib/python2.7/site-packages:/home/daniel/qiime_software/pyqi-0.3.1-release/lib/python2.7/site-packages:/home/daniel/qiime_software/MySQL-python-1.2.3-release/lib/python2.7/site-packages:/home/daniel/qiime_software/mpi4py-1.2.2-release/lib/python2.7/site-packages:/home/daniel/qiime_software/setuptools-0.6c11-release/lib/python2.7/site-packages:/home/daniel/qiime_software/gdata-2.0.17-release/lib/python2.7/site-packages:/home/daniel/qiime_software/pysqlite-2.6.3-release/lib/python2.7/site-packages:/home/daniel/qiime_software/qcli-0.1.0-release/lib/python2.7/site-packages:/home/daniel/qiime_software/tornado-3.1.1-release/lib/python2.7/site-packages:/home/daniel/qiime_software/SQLAlchemy-0.7.1-release/lib/python2.7/site-packages:/home/daniel/qiime_software/pyzmq-2.1.11-release/lib/python2.7/site-packages:/home/daniel/qiime_software/numpy-1.7.1-release/lib/python2.7/site-packages:
Any help is appreciated.
Python looks up modules in the environment variable PYTHONPATH, so try echo $PYTHONPATH on the shell. Normally, this should be empty.
Otherwise you can try to run spyder from a dedicated environment, so try something like:
$ conda create -n spydertest spyder
$ source activate spydertest
$ spyder
I have successfully created a virtual environment with virtualenvwrapper using python3 at /usr/local/bin/python3 as default interpreter. My system python is python2.7
I can't use pip3 in this virtual environment because it keeps looking inside the default /usr/lib/python2.7/dist-packages
(python3.3.3)╭ ➜ xxx#xxx:~VIRTUAL_ENV/bin
╰ ➤ pip3.3
Traceback (most recent call last):
File "/home/xxx/virtualenv/python3.3.3/bin/pip3.3", line 7, in <module>
from pip import main
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.basecommand import command_dict, load_command, load_all_commands, command_names
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 11, in <module>
from pip.baseparser import parser, ConfigOptionParser, UpdatingDefaultsHelpFormatter
File "/usr/lib/python2.7/dist-packages/pip/baseparser.py", line 5, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 45
def _bypass_ensure_directory(name, mode=0777):
^
SyntaxError: invalid token
Am I forgetting something?
I've also tried to install python3 into a custom directory inside /opt but that doesn't help.
Got it. My system $PYTHONPATH contains /usr/lib/python2.7/dist-packages so I simply removed it from the path and everything is now working properly.