FileNotFoundError when running virtualenv - python-3.x

When I run the command python -m virtualenv venv
I get the following output:
Traceback (most recent call last):
File "runpy.py", line 184, in _run_module_as_main
File "runpy.py", line 85, in _run_code
File "C:\python\lib\site-packages\virtualenv.py", line 2328, in <module>main()
File "C:\python\lib\site-packages\virtualenv.py", line 713, in main symlink=option.symlink)
File "C:\python\lib\site-packages\virtualenv.py", line 925, in create_environment site_packages=site-packaged clear= clear, symlink=simlink
File "C:\python\lib\site-packages\virtualenv.py", line 1147, in install_python writefile(site_filename_dst, SITE_PY)
File "C:\python\lib\site-packages\virtualenv.py", line 362, in writefile with open(dest, 'wb') as F:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\python\\sites\\venv\\python35.zip\\site.py'
When I navigate to the 'venv' folder the file structure is completely unpopulated with only C:\Python\sites\venv\Lib\site-packages (which is completely empty)
I have tried re-installing virtualenv and googling the issue with no avail. Please advise

Have you correctly installed the python on your machine? I also run into a similar issue earlier. It was caused by my python installation.
You see if you check your python path and go to the Lib folder, I assume there was no site.py. You can:
reinstalled your python, make sure it has correctly installed (check the Lib and Script folder)
correct your python path to your user/system environment: I assume you are using Window OSX, e.g: setx PYTHONHOME "C:\<your_python_path>"; add that to your path: setx PATH "%PATH%;%PYTHONHOME%"
Don't forget to add the Script path as well, if you want to access pip without python -m
Cheers!!

Related

faild to make a new virtualenv having python2.7 and python3.6 on ubuntu 18.04

I am trying to use virtualenv to install some python modules for deep learning. I'm on Ubuntu 18.04 where there was python2.7 intalled. Somehow I installed python 3 and made a virtualenv called dl4cv where I can work on deep learning projects. Now that I'm trying to make a new virtualenv mkvirtualenv temp after installing virtualenvwrapper, I got an error as shown below :
hdafa#hdafa-HP-ProBook-450-G5:~$ mkvirtualenv temp
Running virtualenv with interpreter /usr/bin/python2
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/virtualenv.py", line 2375, in <module>
main()
File "/usr/lib/python3/dist-packages/virtualenv.py", line 724, in main
symlink=options.symlink)
File "/usr/lib/python3/dist-packages/virtualenv.py", line 946, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/lib/python3/dist-packages/virtualenv.py", line 1157, in install_python
mkdir(lib_dir)
File "/usr/lib/python3/dist-packages/virtualenv.py", line 329, in mkdir
os.makedirs(path)
File "/usr/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/home/hdafa/.virtualenvs/temp'
any idea of how I can fix it?
You've been using sudo too much. Please stop.
First, fix permissions of your home:
sudo chown -R hdafa /home/hdafa
From now on please use only virtual environments and avoid sudo except for system administration tasks.
It looks like your OS is denying permission to make a directory. Try running the command with root permissions: sudo mkvirtualenv temp. The keyword sudo uses root permissions, and so it should be able to create the directory that it needs to.

OSError: [Errno 30] Read-only file system: '/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/docs' on intel dev cloud

I am unable to install packages in my intel dev cloud. I tried installing packages using pip from bash shell. I also created a new conda environment and tried installing packages there. It didn't work either. I think the problem is with permissions in file system. The error says "read-only file system" as you can see.
Any suggestions can greatly help.
P.S: I am trying to install keras and sklearn
please check the error log below.
Installing collected packages: keras
Exception:
Traceback (most recent call last):
File "/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/glob/intel-python/versions/2018u2/intelpython3/lib/python3.6/site-packages/docs'
I think the problem is with permissions in file system. The error says "read-only file system"
Yes, you correctly diagnosed the problem.
You need to choose a writable filesystem to write the installed files to.
You may find the df and mount commands helpful. Start with man df.
With the guidance of #J_H I found out the answer.
pip usually tries to install packages globally, which is not allowed on shared platforms like Intel DevCloud. Hence we need to install packages for single user that is you.
Hence
pip install --user keras
installs keras in your home directory and you are not restricted to write in your home directory. Problem Solved!

Pyinstaller does not look for the file inside the Python Virtual Environment

I want to convert Python code into standalone executable , the code uses numpy, scipy, and Pymc3 modules. I am using Python 3.6.4. I have created the project using Virtual Environment in Pycharm IDE. The command that I used to run pyinstaller is as follows:
venv/Scripts/pyinstaller --onefile src/POD.py
venv being the folder where virtual environment is stored and src being the folder where my Python source code ie. POD.py is saved. Pyinstaller runs just fine generates some warning message, but when I try to run the executable generated by pyinstaller it thrown as error
Traceback (most recent call last):
File "POD.py", line 196, in <module>
File "POD.py", line 79, in train
File "Lib\site-packages\theano\tensor\var.py", line 155, in __mul__
File "Lib\site-packages\theano\gof\op.py", line 615, in __call__
File "Lib\site-packages\theano\tensor\elemwise.py", line 482, in make_node
File "Lib\site-packages\theano\tensor\elemwise.py", line 438, in get_output_info
File "Lib\site-packages\theano\tensor\elemwise.py", line 157, in __init__
File "Lib\site-packages\theano\gof\op.py", line 1308, in __init__
File "Lib\site-packages\theano\gof\op.py", line 1331, in load_c_code
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI126642\\theano\\tensor\\c_code\\dimshuffle.c'
[4756] Failed to execute script POD
Seems like it is trying to find the file dimshuffle.c outside of the virtual environment. In-fact the I can see that there is folder inside virtual environment which has the dim_shuffle.c code. I can find it inside virtual environment in following folder.
venv/Lib/site-packages/theano/tensor/c_code/dimshuffle,c
My question is how do I instruct pyinstaller to look for dimshuffle inside virtual environment folder?
You can,
extend the sys.path by editing the spec file.
pyi-makespec --paths=/path/to/thisdir \
--paths=/path/to/otherdir myscript.py
List the hidden imports using the spec file.
for more info refer this

install issue with python - spacy package in anaconda environment

I'm attempting to follow this tutorial to install the natural language processing package spaCy into a python 3 anaconda environment, windows 8
I opened console, cd-ed to my site-packages folder, activated environment, pip-ed for install, everything seemed fine except I couldn't run the second command here
$ pip install spacy
$ python -m spacy.en.download
Now I can successfully load the package but when I run the second line below, I get the following error
>>> from spacy.en import English #this works
>>> nlp = English() #this doesn't
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\garrett\Anaconda\envs\py3k\lib\site-packages\spacy\en\__init__.py", line 64, in __init__
get_lex_props=get_lex_props)
File "spacy/vocab.pyx", line 42, in spacy.vocab.Vocab.__init__ (spacy/vocab.cpp:2216)
OSError: Directory C:\Users\garrett\Anaconda\envs\py3k\lib\site-packages\spacy\en\data\vocab not found -- cannot load Vocab.
I think that it is due to the fact that I couldn't run python -m spacy.en.download
Can anyone give me an idea of what python -m spacy.en.download is supposed to be doing?
Can anyone provide a walkthrough for how to get spaCy installed in an anaconda environment?
here's the error I get after setting the directory, activating python env, running command. The first several times I tried, my spyder editor went unresponsive and I killed the console, the most recent time I got this error
$ cd C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages
$ C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages>activate py3k
$ [py3k] C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages>python -m spacy.en.download
Moving existing dir C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages\spacy\en\data to /tmp
Traceback (most recent call last):
File "C:\Users\garrett\Anaconda\envs\py3k\lib\runpy.py", line 160, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Users\garrett\Anaconda\envs\py3k\lib\runpy.py", line 73, in _run_code
exec(code, run_globals)
File ".\spacy\en\download.py", line 56, in <module>
plac.call(main)
File ".\plac_core.py", line 309, in call
cmd, result = parser_from(obj).consume(arglist)
File ".\plac_core.py", line 195, in consume
return cmd, self.func(*(args + varargs + extraopts), **kwargs)
File ".\spacy\en\download.py", line 51, in main
shutil.move(DEST_DIR, '/tmp')
File "C:\Users\garrett\Anaconda\envs\py3k\lib\shutil.py", line 521, in move
raise Error("Destination path '%s' already exists" % real_dst)
shutil.Error: Destination path '/tmp\data' already exists
appreciate any help or advice you can provide
You have hit this bug which should be already fixed in the last version. Apparently spacy can't download the data because the destination already exists (may be from a previous interrupted download). A workaround would be to delete the /temp/data folder and retry the download.

Unable to setup a virtualenv in ubuntu

I am following these steps to setup a virtual environment in Ubuntu 13.10 64-bit.
https://askubuntu.com/questions/244641/how-to-set-up-and-use-a-virtual-python-environment-in-ubuntu
After setting up the various things in bashrc and then on executing source .bashrc. I get the following traceback.
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
from stevedore import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/__init__.py", line 11, in <module>
from .extension import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/extension.py", line 4, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2825, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 710, in subscribe
callback(dist)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2825, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2257, in activate
self.insert_on(path)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2364, in insert_on
self.check_version_conflict()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2403, in check_version_conflict
for modname in self._get_metadata('top_level.txt'):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2251, in _get_metadata
for line in self.get_metadata_lines(name):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1219, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1211, in get_metadata
return self._get(self._fn(self.egg_info,name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1326, in _get
stream = open(path, 'rb')
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.2-py2.7.egg/EGG-INFO/top_level.txt'
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenv has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
It seems that it is unable to find the installation of python. I too am puzzled bacause on executing "which python", I get /usr/bin/python but when I got /usr/bin, I am unable to find the python directory .Please help...
Thanks.
Permission denied seems like u need to be root to do that. Maybe you should use "sudo" before using the command which gives you the error
Did you install virtualenvwrapper? If yes, then sudo like mentioned by user2270433. If no, then install that and proceed with the instructions. I haven't used virtualenvwrapper, but the standard steps for virtualenv in my bootstraps are like this...
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo -n python ez_setup.py && sudo python get-pip.py
sudo -n pip install virtualenv

Resources