I managed to install an OpenAI gym Atari environment in a PyCharm project. (It took so much trial and error that I no longer know what finally got it to work. But now it does.)
I copied the project directory, created another project from the copy, and tried to run the same program that ran before -- actually the copy of the program that was created when I copied the directory. Now I get an error message saying that the Atari environment is not installed -- or not installed correctly.
Traceback (most recent call last):
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari\atari_env.py", line 9, in <module>
import atari_py
ModuleNotFoundError: No module named 'atari_py'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/rabbott/Google Drive/CSULA/ECST/CS Dept/CS 4660/2018/OpenAI_Models/Q-Learning-Framework - Copy/Interactive_Atari-2018-10-27-2230.py", line 416, in <module>
GameControl(Bot()).play('Pong-v0')
File "C:/Users/rabbott/Google Drive/CSULA/ECST/CS Dept/CS 4660/2018/OpenAI_Models/Q-Learning-Framework - Copy/Interactive_Atari-2018-10-27-2230.py", line 30, in play
env = gym.make(game)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 167, in make
return registry.make(id)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 119, in make
env = spec.make()
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 85, in make
cls = load(self._entry_point)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 14, in load
result = entry_point.load(False)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 2324, in load
return self.resolve()
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 2330, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari\__init__.py", line 1, in <module>
from gym.envs.atari.atari_env import AtariEnv
File "C:\Users\rabbott\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari\atari_env.py", line 11, in <module>
raise error.DependencyNotInstalled("{}. (HINT: you can install Atari dependencies by running 'pip install gym[atari]'.)".format(e))
gym.error.DependencyNotInstalled: No module named 'atari_py'. (HINT: you can install Atari dependencies by running 'pip install gym[atari]'.)
Process finished with exit code 1
When I try to install it again, I run into the same problems I had originally. In particular, I have no idea what will get the Atari environment installed correctly.
Is there some relatively easy and straightforward way to use the installation that already works in the copy of the project?
Thanks.
Safest way to install gym and work without any issue is by using a python virtual environment. It is always better to have a separate virtual environment for your gym projects. Please use conda or pipenv to create a virtual environment.
Example in pipenv
install pipenv
pip install --user pipenv
go inside your project directory ( where your .py file resides )
cd myproject
install gym
pipenv install gym
install atari and any other dependency in your virtual environment as follows.
pipenv install atari-py
run your code
pipenv run python main.py
This will make sure your code work without any issue.
NOTE
Pipenv creates different virtual environments for each project. If you want to use the same environment for multiple projects use virtual environments in conda as mentioned above.
Related
I'm trying to build pyslam project, and the install.sh file was provided. But when I executed install.sh, the main.py didn't work.
https://github.com/luigifreda/pyslam#install-pyslam-under-ubuntu-2004
Full Installation
In order to run main_slam.py with venv, get in the root of this repository and run the following command:
$ . install_all_venv.sh
N.B.: do not forget the dot! (without '/' !)
This will compile the required thirdparty packages and will also activate the created pyslam environment. Now, from the same terminal, you can run:
$ python3 -O main_slam.py
The result was
(pyslam) (base) ict-526#ict526-MS-7D32:~/pyslam$ python3 -O main_slam.py
Traceback (most recent call last):
File "/home/ict-526/pyslam/main_slam.py", line 27, in <module>
from config import Config
File "/home/ict-526/pyslam/config.py", line 27, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
I think the packages didn't install in the venv (pyslam). How can I fix this situation?
My environment is ubuntu20.04, and python 3.9.7.
According to the installaion instruction, python 3.6.9 was required. After install_all_venv.sh, the pyslam venv support python 3.9.7...
I did a fresh install of Python 3.8.3 for Windows 10. I can't get pip to work, it keeps complaining about module pip._internal.utils that can't be found.
When I run pip -v as a regular user, this is what I get:
Traceback (most recent call last):
File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Python38\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\verhager\AppData\Roaming\Python\Python38\site-packages\pip\__init__.py", line 1, in <module>
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
File "C:\Users\verhager\AppData\Roaming\Python\Python38\site-packages\pip\_internal\__init__.py", line 1, in <module>
import pip._internal.utils.inject_securetransport # noqa
ModuleNotFoundError: No module named 'pip._internal.utils'
I have tried reinstalling, rebooting, running as Administrator, reinstalling pip with get_pip.py, but nothing has worked sofar.
When searching, I found several people having similar issues on different OSes. It seems like I've tried all suggested solutions, but nothing has worked for me sofar.
Reinstalling didn't solve my problem. That is, not before I really made sure that nothing was left behind.
My Python install was in C:\Python38\. After uninstalling python, this directory remained and contained some left over modules, like pip. I manually deleted the whole C:\Python38 folder.
Then, I checked my AppData folder in my home dir. Everything in this folder and all subfolders that was related to Python or Python modules, I deleted as well. Keep in mind AppData is a hidden folder, so it you might have to enable showing of hidden files and folders in the explorer first.
Finally, I removed all Python folders from my PATH environment variables (system as well as user).
After that, I did a new install of Python 3.8 and everything works as expected.
What I think the problem was? Some left overs from a previously (broken) installation messed with my environment, causing pip not resolving required modules.
I had the same error as you, with Windows 10. I also investigated and found that the "pip._internal.utils" package was missing. I was able to overcome this issue without an extensive Cleanup/Reinstall of Python.
After ensuring the following
That the Python Binary and Scripts folders were part of %PATH%
That I was on a Console Window with Administrator privileges
I ran the following command
python -m ensurepip --default-pip
With this command the package was installed. I did a general verification of the installation with the following command.
pip --version
Which returned the with specs. This command invokes the missing package.
I faced the same issue and here's how I resolved this error on windows 7 -
Navigate to C:\Users<user-name>\AppData\Roaming\Python\Python38\site-packages
Delete pip folder
This is introduced when I read this messsage
"You should consider upgrading via the 'python -m pip install --upgrade pip' comand." and followed using the same command for upgrading.
I have used matlab, but I am only 2 weeks into Python. I downloaded anaconda 3.7 and am using spyder 4.1.3. I was following a youtube tutorial on python. I was doing well until the guy access the cmd prompt (I use Windows 10) from within his IDE.
I didn't know how to so I googled it and to do so I found on pypi.org that all I had to do was run pip install spyder-terminal in the cmd prompt. I tried this but at the end it said that I had a permissions error and to try the --user option. I copied and pasted the exact error and saw on git hub, to create an environment or run python -m pip install --user [INSERT PACKAGE NAME].
I don't really understand hat an environment is so I did the second --user way. I ran python -m pip install --user spyder terminal I got an error about a location not being in the path variable, so i just copied the file location that it referenced and copied it the the path. I then went to open up spyder 4.1.3 and i got the error
Traceback (most recent call last):
File "C:\Users\Aaron\anaconda3\lib\site-packages\qtpy\__init__.py", line 204, in
from PySide import __version__ as PYSIDE_VERSION # analysis:ignore
ModuleNotFoundError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Aaron\anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\Users\Aaron\anaconda3\lib\site-packages\spyder\app\start.py", line 201, in main
from spyder.app import mainwindow
File "C:\Users\Aaron\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 53, in
requirements.check_qt()
File "C:\Users\Aaron\anaconda3\lib\site-packages\spyder\requirements.py", line 41, in check_qt
import qtpy
File "C:\Users\Aaron\anaconda3\lib\site-packages\qtpy\__init__.py", line 210, in
raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found"
I tried opening it again and got the same error. I then tried uninstalling an dre-installing spyder in the anaconda navigator and got the same error. I tried removing the location I added to path and running "pip uninstall spyder-terminal", it said it was removed and I go the same error.
If possible, I am seeking specific steps in layman's terms, because all my knowledge thus far has come from the first 2 hours of a "cool things in python" type video.
I need to open SVS images in Python 3.7 and it seems that Openslide is the only module capable of opening images of that size (30k*30k pixels). I have used pip install openslide-python as well as python -m pip install openslide-python and pip 3 install... etc.
I know the module has been successfully installed because if I run any of those commands again the command line returns requirement already satisfied however when I run Python and try to import openslide it gives the error at the bottom.
My guess was that the .whl or .tar.gz files were in the wrong path so I made a bunch of copies and put them in the openslide folders within the Anaconda3 folder. The error persists. I have included the full error code below for clarity.
Extra: If I run help("modules") openslide shows up along with numpy, math, sklearn etc. I can import and run all other modules without issue.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\brimk\Anaconda3\lib\site-packages\openslide\__init__.py", line 29, in <module>
from openslide import lowlevel
File "C:\Users\brimk\Anaconda3\lib\site-packages\openslide\lowlevel.py", line 41, in <module>
_lib = cdll.LoadLibrary('libopenslide-0.dll')
File "C:\Users\brimk\Anaconda3\lib\ctypes\__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "C:\Users\brimk\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
My issue was resolved by the answer from my hero!
It seems that, at least for Openslide, running Python from the Path to the Bin is the easiest solution. It can be done this way.
Download the Windows Binary here.
Extract the download to whatever path you want.
Open command window
pip3 install openslide-python (pip2 if Python 2)
cd C:\Users\Path\to\Openslide-Win64-20171122\bin
python
import openslide
In the future you will have to run python from the path to the Openslide bin (Step 4). This can be done more rigorously by adding that file path to the PATH as described in detail here as well as in the answer above.
I am experiencing a problem when using virtualenv in openSuSE 12.3 with Python3:
I installed the python3 and python3-devel packages.
Then I installed the newest distribute and pip and finally virtualenv using pip.
When I try to create a virtualenv I get the following error:
$ virtualenv-3.3 venv01
Using base prefix '/usr'
New python executable in venv01/bin/python3.3
Also creating executable in venv01/bin/python
Installing distribute.........................................................................................................................................................................................................................................................................................................................................................................................................done.
Installing pip....
Complete output from command /home/user/venv01/bin/python3.3 -x /home/user/venv01/bin/easy_install /usr/local/lib/pytho...ort/pip-1.3.1.tar.gz:
/home/user/venv01/bin/python3.3: can't open file '/home/user/venv01/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv-3.3", line 9, in <module>
load_entry_point('virtualenv==1.9.1', 'console_scripts', 'virtualenv-3.3')()
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 979, in main
no_pip=options.no_pip)
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 1094, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 667, in install_pip
filter_stdout=_filter_setup)
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 1057, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/user/venv01/bin/python3.3 -x /home/user/venv01/bin/easy_install /usr/local/lib/pytho...ort/pip-1.3.1.tar.gz failed with error code 2
Running it with -vvv yields some interesting output that shows that distribute
is extracted to <venv>/local/lib/python3.3/site-packages/.
I wonder why distribute is not installed into <venv>/lib/python3.3/site-packages/?
Does anyone have an idea why this happens and how I can use virtualenv in
openSuSE without compiling python3 myself?
[now fixed in latest patches from opensuse]
[oh! i just realised you are the same person as the original link. sorry. but i will leave this as it is a top result for google search on this issue (was searching myself for any update) so it may help others.]
this is a known issue, discussed at https://forums.opensuse.org/english/get-technical-help-here/applications/484475-using-virtualenv-python-3-a.html and with an open bug at https://bugzilla.novell.com/show_bug.cgi?id=809831
the only work-around i know of is to install everything yourself. it's not so hard, and i describe what is necessary at http://www.acooke.org/cute/GettingPyt0.html
basically:
install python 3.3 from source (do an "altinstall" to install as /usr/local/bin/python3.3)
fix the lib issue (link lib_dynload from /usr/local/lib64/python3.3 to /usr/local/lib/python3.3)
install distutils
install virtualenv
then you can use python3.3 and virtual-env-3.3 etc as expected.